Explore BrainMass
Share

Explore BrainMass

    Java driver and fraction class that adds,multiplies,prints

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    This is the farthest I have gone. Am stuck, where do i go from here?

    public static void main(String[] args)
    {
    Scanner stdIn = new Scanner(System.in);
    Fraction c, d, x; // Fraction objects

    System.out.println("Enter numerator; then denominator.");
    c = new Fraction(stdIn.nextInt(), stdIn.nextInt());
    c.print();
    ...

    © BrainMass Inc. brainmass.com October 9, 2019, 11:56 pm ad1c9bdddf
    https://brainmass.com/computer-science/java/java-driver-and-fraction-class-that-adds-multiplies-prints-273233

    Solution Preview

    Attached are 2 files. The Main.java contains your driver class, while Fraction.java contains the Fraction class.
    The Main.java captures user input and creates instances of the Fraction class and then displays the ...

    Solution Summary

    Solution contains two java source code files. The Main.java contains your driver class, while Fraction.java contains the Fraction class. The Main.java captures user input and creates instances of the Fraction class and then displays the results. This is a simple scenario, in which the user is prompted 3 times to enter numerator and denominator values. It will perform addition and multiplication with the first two entries and prints as double the third entry.

    Program in action looks like below:

    Enter numerator; then denominator.
    200/2
    Enter numerator; then denominator.
    300/4
    Sum:
    1400.0/8.0 = 175.0
    Product:
    60000.0/8.0 = 7500.0
    Enter numerator; then denominator.
    100/3

    $2.19