Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello guys, Please I need help for this homework in Java language: Assignment Rational Numbers Objects, Classes and Methods PROGRAM SPECIFICATIONS For this assignment you

Hello guys, Please I need help for this homework in Java language:

Assignment Rational Numbers Objects, Classes and Methods PROGRAM SPECIFICATIONS For this assignment you will need to write two classes. The first class will be named Rational.java. A rational number is a fraction, it has a numerator and a denominator. The details of the Rational class are below. The second class will be named RationalDriver.java. This class will contain the main method. The details of the RationalDriver class are also below. Rational.java Default value constructor that sets the numerator to 1 and the denominator to 1 Explicit value constructor that sets the numerator and denominator to values specified by the user Get Methods Set Methods A toString Method An equals Method An add Method A subtract Method A reduce method (used internally) Data variables appropriate to a rational class Additional methods you deem necessary RationalDriver.java The RationalDriver class will create and manipulate objects of type Rational. The class will contain the main method and will accommodate the following: An array of rational objects. Code to load the array with Rationals. Values are: 2/3, 2/18, 3/12, 9/3, 2/5, and 22/7 (note you must load the array with enlarged fractions like 2/18 and your program will reduce the fraction during object construction.) After loading the array of Rational number objects, a menu is continually displayed. The menu will have the following options: 1. Display the value of a Rational object. Prompt for the index. 2. Change the value of a rational. Prompt for the index of the Rational to be changed, and then the new denominator and new numerator. (You may wish to create a new Rational object to accomplish this.) 3. Add two Rational objects together and display the sum as a new Rational object. (Prompt for two index values that indicate the two Rationals to be added.) 4. Subtract two Rational objects and display the difference as a new Rational object. (Prompt for two index values that indicate the two Rationals. The second will be subtracted from the first.) 5. Sort the array of Rational number objects. Use a sort method from your SortSearchUtil class. 6. Print the array of Rational number objects to the screen. 7. Quit Note: all rational numbers will be in their reduced form. If the user enters 2/4 the rational number that will be displayed is 1/2. You are guaranteed that an integer will be entered for the numerator and the denominator. A rational number can be negative. HINTS Solve the problems systematically testing as you go You should be able to write the get, set and default value constructor. As we cover topics in class you should make the appropriate changes to your code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago

Question

3. How would this philosophy fit in your organization?

Answered: 1 week ago

Question

How would you assess the value of an approach like this?

Answered: 1 week ago