Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me do it? Thanks Note: 1. Make sure the FractionTest.java can be compiled together with your Fraction class. 2. Submit only the

Can someone help me do it? Thanks
Note:
1. Make sure the FractionTest.java can be compiled together with your Fraction class.
2. Submit only the Fraction.java file
3. The FractionTest class is only for testing purpose. We will change the fraction numbers in the FractionTest program when testing your submission.
image text in transcribed
AT&T LTE 10:03 AM gastate.view.usg.edu You are given two classes, first is class Fraction which have methods to do various calculations related with fractional numbers. Second is class Fraction Test which uses the methods defined in Fraction for various inputs and print out the results. The Fraction Test class is already given so you don't need to do anything. Class Fraction already have some predefined methods, you just need to add the following methods. 1. Add two more constructors. One of the constructors will have no parameters; it initializes the fraction to 0/1. The other constructor will have one parameter representing the numerator of the fraction; the denominator of the fraction will be 1 2. Add divide method to take another Fraction as the parameter and return a new Fraction that is the division of current Fraction and the Fraction in the parameter. (public Fraction divide(Fraction f) 3. Add Scaleup and scaledown methods to the Fraction class. The scaleup method will take a factor as the parameter and multiply the numerator by the factor. The scaledown method will take a factor as the parameter and multiply the denominator by the factor(scaleown). You must check that the scaledown factor is not 0. If it is 0, a warning message is printed out and no scaling is operated. 4. Add a scale method which will have two parameters: factor and flag. The flag is boolean. If flag is true, then scale up the fraction(scaleup); otherwise scale down the fraction. (Use methods from no. 3) Only create the required methods and do not create methods other than asked. You do not need to simplify the fractions to lower values (If the result is 10/20, no need to simplify to 1/2). For the given inputs, your final output should be (Do not modify Fraction Test class): 1. The addition result is:29/8 2. The division result is 60/80 3. Scaling Up firstFraction 25/8 4. Scaling Down firstFraction: 5/40 5. Scaling firstFraction: 50/8 6. Scaling secondFraction: 3/10 Warning: Cannot scale down with 0

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 Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Define marketing concepts.

Answered: 1 week ago

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago

Question

8. Providing support during instruction.

Answered: 1 week ago