• 100% Satisfaction Guarantee

LogicPro, Engineer
Category: Homework
Satisfied Customers: 11993
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
29751445
LogicPro is online now

### Resolved Question:

Submitted: 3 years ago.
Category: Homework
Expert:  LogicPro replied 3 years ago.
Hi,
Let me know the details.
Customer: replied 3 years ago.

I am having problems with the add method in my fraction class. I would like an answer on how to do this or how to get the answer at very least. When it prints the sum I get a sum of 0/0.

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.

4

Basic Requirements

Write a driver and fraction class that performs addition, multiplication, prints the fraction, and prints as a double.

LastNameFirstNameProg7.java

Provide a driver class, LastNameFirstNameProg7, that demonstrates this Fraction class. The driver class should contain this main method:

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

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

x = new Fraction(); // create a fraction for number 0

System.out.println("Sum:");
x.print();
x.printAsDouble();

x = new Fraction(1, 1); // create a fraction for number 1

System.out.println("Product:");
x.multiply(c).multiply(d);
x.print();
x.printAsDouble();

System.out.println("Enter numerator; then denominator.");

x = new Fraction(stdIn.nextInt(), stdIn.nextInt());
x.printAsDouble();
} // end main

Note that this demonstration driver does not call the accessor methods. That’s OK. Accessor methods are often implemented regardless of whether there’s an immediate need for them. That’s because they are very useful methods in general and providing them means that future code can use them when the need arises.

16

Fraction.java

Write a Fraction class called Fraction.java that implements these methods:

add ─ This method receives a Fraction parameter and adds the parameter fraction to the calling object fraction.
multiply ─ This method receives a Fraction parameter and multiplies the parameter fraction by the calling object fraction.
print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)
printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)
Separate accessor methods for each instance variable in the Fraction class.

56

NOTE: Complete your activity and submit it to the Dropbox in eCollege

4

Total Points

80

Sample Output

Enter numerator; then denominator.
5
8
5/8

Enter numerator; then denominator.
4
10
4/10
Sum:
82/80
1.025
Product:
20/80
0.25

Enter numerator; then denominator.
6
0
infinity

Expert:  LogicPro replied 3 years ago.
When do you need this answer?
Expert:  LogicPro replied 3 years ago.

You need to spend \$3 to view this post. Add Funds to your account and buy credits.
LogicPro, Engineer
Category: Homework
Satisfied Customers: 11993
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

### What Customers are Saying:

• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Previous | Next >
• Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
• This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
• Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
• I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
• Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
• Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
• He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX

• ### LogicPro

#### Satisfied Customers:

4925
Expert in Java C++ C C# VB Javascript Design SQL HTML
< Last | Next >

### LogicPro

#### Satisfied Customers:

4925
Expert in Java C++ C C# VB Javascript Design SQL HTML

### Manal Elkhoshkhany

#### Satisfied Customers:

4538
More than 5000 online tutoring sessions.

### Linda_us

#### Satisfied Customers:

3138
Post Graduate Diploma in Management (MBA)

### Chris M.

#### Satisfied Customers:

2602
Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

### F. Naz

#### Satisfied Customers:

2126
Experience with chartered accountancy

### Bizhelp

#### Satisfied Customers:

1887
Bachelors Degree and CPA with Accounting work experience