Display the contents of both arrays on the screen

Assignment Help Basic Computer Science
Reference no: EM131079449

have a trouble with (f) of "RationalAssignment",sorting. My code isTestRational.java
RationalAssignment:

1. Make a class Rational to provide at least following methos and constructors:
Rational r1= new Rational (3,5);
Rational r2= new Rational (4,7);
Rational r3=r1.add(r2);
// also sub,mult,divide methods
Other that four operations you should provid methos that you think is useful for user of your class.

2. Write a JFrame or JApplet (file name: TestRational.java) that performs the following tasks:
a) Define two arrays of size 10. Each element in the array references to a Rational object that you wrote in Problem 1 above.
Rational a[], b[];
a = new Rational[10];
b = new Rational[10];

c) Display the contents of both arrays on the screen using JTextArea.b) Initialize the arrays in Question a) by creating random Rational numbers. Do this by generating two random numbers between 1 and 9 for each Rational and using the numbers as the numerator and denominator. Denominator should be greater than Numerator. You should generate random numbers with Math.random.

d) Add a Scrollbar to JTextArea for scrolling up or down.

e) For each public method in Rational class, create a corresponding JButton object. When the user clicks on a button, the actionPerformed listener should execute the corresponding Rational method for all the elements in the two arrays and store the results in a new array. You should then display the result array in the JTextArea using the setText method. For example, if the user hits the add button you should loop through all the elements in arrays and execute:
c[i] = a[i].add(b[i]);

f) If the user hits the sort button, uses the JTextArea method append to append the results of sorting.

Attachment:- 1603115_1_TestRational.zip

Reference no: EM131079449

Questions Cloud

Find a complementary or competing company in same industry : What are the security or control issuesthat should be addressed as part of the technology selection process for Kirby's business?
Long run costs for blockbuster : What were the long run costs for Blockbuster and the divisible inputs? Who were their competitors?
Ratio of income to capital in two countries : 1. What is the ratio of income to capital in these two countries? 2. What is the saving rate in country Z? 3. What is the growth rate of capital per worker in country A?
Forensic significance of the condition known as cadaveric : I need help with these questions: What are the objectives of death investigation and why they are important?
Display the contents of both arrays on the screen : If the user hits the sort button, uses the JTextArea method append to append the results of sorting.
Indicate audit procedures that should have brought the item : For each of the above events or transactions, indicate the audit procedures that should have brought the item to the attention of the auditor and the form of disclosure in the financial statements including the reasons for such disclosure.
Role of economics in health care : Describe why it is important for health policymakers to be familiar with basic economic concepts? Explain role of economics in health care? Examine the use of economic models to help forecast the impact of policy on health care delivery?
Company zero-tolerance harassment policy : Another student asked this same homework assignment previously on this site and I cannot use any of the material (powerpoint slides) that a tutor helped her with. I need something orginal and that has not been turned into any other colleges since ..
Prepare a report for mr tomas gurny the it manager at hbzs : CIS5308 Management of IT Services. For the purpose of this assignment, assume the role of a consultant who have been hired by HBZS to contribute to a review of IT Service Management at HBZS. You will prepare a report for Mr Tomáš Gurny, the IT Mana..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  How the link-state algorithm builds the routing table

For the network given in Figure 4.48, show how the link-state algorithm builds the routing table for node D.

  Develop a java applet

This method should be called once when the applet begins execution and each time the user answers the question correctly. All drawing on the applet should be performed by the paint method (usually indirectly through the repaint method).

  Evaluate why cost is not one of the five core metrics

Evaluate why cost is not one of the five core metrics of the SLIM model and speculate on the consequences if cost served as one.

  Determine the source rate r

Suppose that 30 pictures are sent per second. (This digital source is roughly equivalent to broadcast TV standards that have been adopted.) Determine the source rate R (bps).

  Filling all the positions of his cabinet

How many ways are there of filling all the positions of his cabinet if we assume that each position be filled by a different person and do not take into account which position each been has been assigned?

  Eassy on imaginary peripheral device

Come up with an imaginary peripheral device which you think would be useful in personal or business use. Describe what this device would do.

  Write program convert gps coordinates between three notation

For this program write a simple computer program that converts GPS coordinates between three notional forms

  Cope with the emerging complexity

Name the framework, which the diversified organisation should adopt, to enable it to cope with the emerging complexity? Give a reason in support of your answer. State limitations of this framework.

  Program with ascii version of the classic game

This question is about working with 2 dimensional arrays. In this program, you will implement an ascii version of the classic game "Connect 4".

  Findthree definitions object-oriented programming andcompare

The machine language treats a message as bits while object-oriented programming language treats every message as an object

  Determine the steps of the game in the algorithm format

Analyze the computational complexity of the game Concentration. To do so, determine the steps of the game in the algorithm format from Week 4 lectures and figure out how many steps it would take at maximum to finish the game.

  Describe the tasks and business functions

Describe the tasks and business functions that users, managers, and IT staff members perform to achieve specific results

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd