Our Services

Get 15% Discount on your First Order

[rank_math_breadcrumb]

1. Create a new file called Fraction.java 2. In this file, create a class Fraction. a. This class should have 2 attributes, declare it, don’t forget those fields/attributes need to be private b. Crea

1. Create a new file called Fraction.java

2. In this file, create a class Fraction. 

a. This class should have 2 attributes, declare it, don’t forget those fields/attributes need to be private

b. Create 2 constructors,

i. One constructor without any parameter. This constructor will initialize the first attribute to 0 and the second to 1.

ii. The second constructor will have 2 parameters that will initialize the 2 attributes of the Fraction class.

c. Create a getter and a setter for each private fields.

d. Create 4 methods, addition, subtract, multiply, divide.  Don’t forget to declare those methods public so every objects can use  them. Since those methods needs to be called by an instance of the class  Fraction, what do those methods need to achieve the  addition/subtraction/multiplication/division of TWO fractions. The 4  methods need to return a brand NEW fraction result of the addition/subtraction/multiplication/division of the 2 fractions. a/b + c/d = a/b – c/d = a/b * c/d = a/b / c/d 

e. Create a method properFraction,  that has no parameter. This method will return a whole number and  modify the original Fraction to a proper Fraction. For instance:

   Fraction f1 = new Fraction(7,2);// f1-> 7/2   System.out.print(f1.properFraction());// output: 3, f1->1/2   Fraction f2 = new Fraction(2,5); // f2-> 2/5   System.out.print(f2.properFraction());// output: 0, f1->2/5

f. Create a method toString that will return a String made with the 2 attributes with the following format “4/3”.

3.  In the Main.java file, create 3 Fractions with different values. Test  the addition/subtraction/multiplication/division and the properFractions  methods.

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Using the Wall Street Journal or other reliable technology sources, identify a company in an industry that aligns with your major that uses AI for their business operation. In a 400- to 500-word repor

Using the Wall Street Journal or other reliable technology sources, identify a company in an industry that aligns with your major that uses AI for their business operation. In a 400- to 500-word report, describe your selected company, the AI tool/application used for their business operation, and their apparent business goal(s). Briefly

Essay: 700 words minimum to 1000 words maximum (title pages and works cited pages are not included in word count) Provide a brief MDA analysis of your game, focusing on the main mechanics, dynamics an

Essay: 700 words minimum to 1000 words maximum (title pages and works cited pages are not included in word count) Provide a brief MDA analysis of your game, focusing on the main mechanics, dynamics and aesthetics/intended emotional response of your game Discuss the following content in your essay: What you