Question
Not really sure where to even begin. Very new to programming and I will need this code for a later assignment this semester. Can someone
Not really sure where to even begin. Very new to programming and I will need this code for a later assignment this semester. Can someone help me by typing out this code with comments that way I understand how to do this? Thank You!
Note: IN JAVA
You will write a driver program to test the functionality of your fraction class. I think I just need the driver program for now!
Implement a class named Fraction with the following properties:
1. numerator: int type
2. denominator: int type
and the following methods:
1. one default constructor which will create a fraction of 1/1.
2. one constructor that takes two parameters which will set the values of numerator and denominator to the specified parameters.If the denominator is zero, set it to one.
3. int getNum() : retrieves the value of numerator
4. int getDenom(): retrieves the value of the denominator
5. void set(int num, int den): sets the fraction to num/den using the same rules as the constructor from part 2.
6. Fraction add(Fraction frac): adds with another Fraction number and returns the result in a new Fraction object.
7. Fraction sub(Fraction frac): is subtracted by another Fraction frac and returns the result in a new Fraction object.
8. Fraction mult(Fraction frac): multiplies with another Fraction number and returns the result in a new Fraction object.
9. Faction div(Fraction frac): is divided by another Fraction number and returns the result in a new Fraction object.
10. String toString(): return a nicely formatted version of the fraction.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started