Purchase Solution

Java driver and fraction class that adds,multiplies,prints

Not what you're looking for?

Ask Custom Question

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();
...

Purchase this Solution

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

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 ...

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.