1.Fraction that has a numerator and a denominator. The class should

have methods that can:
(a) add and subtract two Fractions together and
return the resulting Fraction,
(b) create a duplicate of itself and return the duplicate,
(c) see if another Fraction is equivalent to itself and return True or False appropriately and
(d) reduce itself to the lowest equivalent Fraction.

.

3 answers

What are you supposed to do for the exercise - pseudocode, public class,...?

Can you pin-point your difficulty with the problem.

Is it the logic or the syntax that gives you problems? I assume you are programming in Java?
Sorry, It's Java, and I am suppose to
write a class to represent one of the following items. Note that each class must a proper constructor even though the constructor is not explicitly named.
So you start off with defining the public class, the instance variables, and the constructors. If you define a constructor with parameters, it is always preferable to define one without to replace the default constructor.
A constructor has the same name as the class, and has no return type.

To make a (shallow) copy of an instance, you will need a copy constructor, which is a constructor which has a single parameter of type equal to the class, such as:
public Fraction(Fraction f){....}

I'll get you started. Post your code if you have difficulties.

public class Fraction
{
// instance variables
private int numerator;
private int denominator;
// constructors
public Fraction()
{ // default constructor, do nothing
}
public Fraction(Fraction original)
{
// write your code here
}
// write your constructor here
// write your other methods here
public static void main(String[] args)
{
// write your code to test the class
}
}
Similar Questions
  1. What kind of fraction is irrational?(1 point)Responses  a fraction with 0 in the numerator a fraction with 0 in the numerator
    1. answers icon 1 answer
  2. Solve this problem. Reduce to lowest terms.Mitchell bought a pizza to share with his friends. He gave fraction numerator 1 over
    1. answers icon 1 answer
  3. Express in simplest form: x2−6x−16/x2−64÷2x+4/x2+x−56(1 point) Responses −x+72 the fraction with numerator negative x
    1. answers icon 1 answer
  4. Question 5 (2 points)Solve this problem. Reduce to lowest terms. Mitchell bought a pizza to share with his friends. He gave
    1. answers icon 1 answer
more similar questions