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

  Define a function that takes argument in name of a csv file

Define a function that takes an argument in the name of a CSV file. This file can have any number of rows. Each row has exactly 10 words separated by comma. Your function should print the total number of four letter words in the file.

  How does the failure region ofthe equality constraint differ

How does the failure region of the equality constraint differ from that of the inequality constraint studied in the earlier examples?

  Policy innovation estimates the music industry loses

The Institute for Policy Innovation estimates the music industry loses $12.5 billion to digital piracy each year. At the same time, Dr. Karen Croxson at the University of Oxford argues that piracy actually helps promote products. Upon what does she b..

  Dos attacks exist for which part of the osi protocol stack

DoS attacks exist for which part of the OSI protocol stack?

  Needs to examine and process the string

Needs to examine and process the string

  Have no hesitation buying over the internet

List some items you would have no hesitation buying over the Internet, some items you might want to think about a bit before buying and some items you would never consider buying over the Internet. Justify you reasons in each case.

  Determine the smallest force p

The coefficient of static friction between the drum and brake bar is µs = 0.4 .

  What are the major types of e-business transactions

What is the advantage of using cloud computing as the platform for e-government?

  Question about materialism philosophy

The mind body dualism, in philosophy, maintains that mind and the brain are 2-distinct categories and one cannot be explained in terms of the other, Mental phenomena are not physical and cannot be explained in physical terms.

  Write a program that will read in a length in meters

Write a program that will read in a length in meters and centimeters and output the equivalent length in feet and inches. Use at least three functions; one for input, one or more for calculating and one for output.

  Explain whether or not the intruder is liable for his action

Differentiate among some of the potential torts that might arise from this business context

  Provide a common and consistent office solution

A school decides it wants to provide a common and consistent "office" solution (a software package that includes word processing, spreadsheets, presentation capabilities, and drawing capabilities) to all students and teachers in the school. The schoo..

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