Jump to content

I am taking a AP Java course, and just failed an assignment.

 

So, if anyone could show me a way that I could have done it, I would be very appreciative.

 

The problem is worded as such:

 

Develop a new class for representing fractions. The numerator and denominator of a fraction are integers. The constructor expects these values as parameters. Define accessor methods to obtain the numerator and denominator. Use the rules of fraction arithmetic to define methods to add, subtract, multiply, and divide fractions. Each of there methods expect a fraction object as a parameter. The object is considered to be the right operand of the operation. The left operand is the receiver object, that is, the one containing the instance variables for the numerator and denominator. Each arithmetic method builds a new instance of the fraction class with the results of its calculation and returns it as the method's value. Finally, include a toString() method that returns a string of the form <numerator>/<denominator>. Write a tester program that exercises all of the methods. 

Please provide the code you wrote for your assignment so we can help point out the problems.

Link to comment
https://linustechtips.com/topic/244855-help-with-a-problem-java/#findComment-3361159
Share on other sites

Link to post
Share on other sites

The problem isn't that my code was wrong, is that I ran out of time and didn't do it.

That is unfortunate, however now that there is no deadline, you have enough time to try doing it for yourself. If you have any specific problems, then come back and ask for help.

Link to comment
https://linustechtips.com/topic/244855-help-with-a-problem-java/#findComment-3361199
Share on other sites

Link to post
Share on other sites

I am taking a AP Java course, and just failed an assignment.

 

So, if anyone could show me a way that I could have done it, I would be very appreciative.

 

The problem is worded as such:

 

Develop a new class for representing fractions. The numerator and denominator of a fraction are integers. The constructor expects these values as parameters. Define accessor methods to obtain the numerator and denominator. Use the rules of fraction arithmetic to define methods to add, subtract, multiply, and divide fractions. Each of there methods expect a fraction object as a parameter. The object is considered to be the right operand of the operation. The left operand is the receiver object, that is, the one containing the instance variables for the numerator and denominator. Each arithmetic method builds a new instance of the fraction class with the results of its calculation and returns it as the method's value. Finally, include a toString() method that returns a string of the form <numerator>/<denominator>. Write a tester program that exercises all of the methods. 

What is that you specifically have a question on? I'm not going to do your assignment for you

CPU: Intel Core i5 2500K | Case: Bitfenix Prodigy | Motherboard: GA-H61N-USB3 | RAM: Corsair 8GB 1333 MHz Video CardEVGA GTX 660 Superclocked 2GB DDR5

Power Supply: Corsair CX 430 | SSD: Samsung 840 120GB | HDD: 2X Seagate Barracuda 500GB 7200rpm | Monitor Asus PB238Q & Asus PB278Q

Mouse: Lenovo N50 | Keyboard: Apple Pro Keyboard | Operating Systems: Hackintosh OS X 10.8.5 & Windows 8.1

Link to comment
https://linustechtips.com/topic/244855-help-with-a-problem-java/#findComment-3365136
Share on other sites

Link to post
Share on other sites

What is that you specifically have a question on? I'm not going to do your assignment for you

It WAS a question on a quiz that I wanted to know in case it was on the test. I took the test and passed, so I don't need this anymore.

༼ つ ◕_◕༽つ GIB 960 ༼ つ ◕_◕༽つ

Link to comment
https://linustechtips.com/topic/244855-help-with-a-problem-java/#findComment-3367876
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×