Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

first picture is the project question and the second picture are the requirements please follow those carefully in terms of the output. comments on the

first picture is the project question and the second picture are the requirements please follow those carefully in terms of the output. comments on the program are necessary too image text in transcribed
image text in transcribed
Programming Projects 1. Write a class called Rational Number that represents a fraction with an integer numerator and denominator. A Rational Number object should have the following methods: public RationalNumber(int numerator, int denominator) Constructs a new rational number to represent the ratio (numerator/denominator). The denominator cannot be e, so throw an IllegalArgumentException if o is passed. public RationalNumber() Constructs a new rational number to represent the ratio (0/1). public int get Denominator() Returns this rational number's denominator value; for example, if the ratio is (3/5), returns 5. public int getNumerator) Returns this rational number's numerator value; for example, if the ratio is (3/5), returns 3. public String toString() Returns a string representation of this rational number, such as "375". You may wish to omit denominators of 1, returning "4" instead of 14/1" An extra challenge would be to maintain your RationalNumber objects in reduced form, avoiding rational numbers such as 3/6 in favor of 1/2, or avoiding 2/-3 in favor of -2/3. Another possible extra feature would be methods to add, subtract, multiply, and divide two rational numbers. Due Thursday 1/7 pg. 584 for online textbook page 914 #1 Need toString method, 2 constructors Don't forget to write the client program that makes two fractions and then Adds, Subtracts, Divides, and Multiply them. Must maintain the fraction in reduced form. The client program must prompt the user for two fraction, must add, subtract, divide, and multiply the two fraction, must output the results. Ex: The sum of 1/3+4/5 = 17/15 or the sum of 1/4+1/4 = 1/2

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Project management skills and/or experience desirable

Answered: 1 week ago