Implement the fraction class

Assignment Help JAVA Programming
Reference no: EM13694526

Question 1: implement the Fraction Class,

Add the following functions into the definition of the Fraction class above main. The main function already has the calls to those functions written. You must write the required functions into the Fraction class such that main will then compile and execute correctly.

• Part 1: Fraction add( Fraction other) returns a Fraction that is the sum of the two Fractions.
• Part 2: Fraction sub( Fraction other) returns a Fraction that is the difference between this Fraction minus the other Fraction.
• Part 3: Fraction mult( Fraction other) returns a Fraction that is the product of the two Fractions.
• Part 4: Fraction div( Fraction other) returns a Fraction that is the quotient of the two Fractions.
• Part 5: Fraction recip() returns a Fraction that is the reciprocal of this Fractions.
• Part 6: void reduce() Does not return a Fraction. Just modifies this Fraction by reducing it to its lowest form the out put should like

f1=22/7
f2=3/2
65/14
23/14
33/7
44/21
7/22

You must keep every Fraction reduced at all times. This means that when a new Fraction is constructed it must be reduced before that constructor exits.

No Fraction at any time may be stored in a form other than its reduced form.

This makes the outputted value of the Fraction consistent in all cases and thus makes script grading easier.

Give the answer of given question and also give details.

Reference no: EM13694526

Questions Cloud

Read each line and create one complex object : Write all complex objects to file complexObj.txt and compute sum of all objects and append the object to the end of complexObj.txt
What is the best way to output the result of a function : What is the best way to output the result of a function?
Write a program that specializes in solving the equations : Write a program that specializes in solving the equations Ax=b by Doolittle's decomposition method, where a is the HIbber matrix of arbitrary size nxn and
What is a user friendly text editor : What is a user friendly text editor which comes pre-installed in Mint that can be used directly in the terminal and Having a system which is not update can be at best
Implement the fraction class : Implement the Fraction Class, Add the following functions into the definition of the Fraction class above main. The main function already has the calls to those functions written. You must write the required functions into the Fraction class such..
Find a regular expression for the language : Find a regular expression for the language over {a, b} that consists of all strings containing exactly one occurrence of substring ab.
How long will it take the program to run : How long will it take the program to run with 1000 processors, if each processor is as fast as the single processor on which the serial program was run?
Describe which base class members may not be inherited : Without considering the access attributes, list and describe which base class members may not be inherited by a derived class and provide a rationale for why this is.
How to sort an array using insertion sort : How to sort an array using insertion sort and track teh number of swaps during the sorting - Can someone provide the answer with reference to data structure?

Reviews

Write a Review

JAVA Programming Questions & Answers

  It inherits the functionality of super class

It inherits the functionality of super class Package and contains an additional data member representing an additional fee per ounce charged for overnight-delivery service.

  Creates an array named odds

Write code that creates an array named odds and stores all odd numbers between -6 and 38 into it using a loop. Make the array's size exactly large enough to store the numbers.

  A java program where the user designates

a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2

  Powerful pain reliever are consumers with headaches

Your target market for the most powerful pain reliever are consumers with HEADACHES. Start with goals and objectives. Do a SWOT. What information is most important for your market? Do some market research.

  Create a book class for the library application project

Create a Book class for the Library application project. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

  Create four classes accountjava checkingjava savingsjava

create four classes account.java checking.java savings.java and accountarray.java.1. for the account class createtwo

  Program obtaining the new scriptdownload and save the

program obtaining the new scriptdownload and save the attached comment cgi mailer script form-mail2.pl to your servers

  Write methods in java

1. int countVowels (String s) That for a given string s, return number of vowels in s.

  Correct example of inheritance

Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild

  Be sure to show all declarations

Write a function call that invokes function a. Be sure to show all declarations. However a complete main is not required.

  Point of sale terminal

a software implementation of a Point of Sale terminal at a typical store. The users of the system are the cashiers sitting at the sales terminals of the store. The users can use the system to manage sales items in the store, customer details and of c..

  Part a -code comprehensionusing the uncommented sample code

part a -code comprehensionusing the uncommented sample code has been provided in moodleanswer the following questions1.

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