Question:
I need to write a program that simulates a fraction calculator any help is welcome?
Mike
2011-06-07 04:36:13 UTC
I need to write a program that simulates a fraction calculator any help is welcome?
I have to a program that simulates a fraction calculator. It should be menu-based and provide options for addition, subtraction, multiplication, and division. Answers have to be displayed in simplest terms.

extra notes:
• You may assume a precondition that user input will be “correct”, i.e., only consist of integers and, if applicable, a slash (fraction bar).
• Input may be a fraction or integer only, i.e., both 2/3 and 3 are both legal inputs. Your program needs to be able to recognize whether a fraction or just an integer is entered and deal with them appropriately. Suggestion-append “/1” to an input integer to make it into a fraction.
• All answers should be in simplest terms.
o 1/2, not 3/6
• If answer is a whole number (including 0), output should reflect so.
o 1, not 4/4
o 3, not 3/1
o 0, not 0/5
• Program should work for negative values
• Error checking should be used to ensure non-zero denominators
• Methods should be used
• Watch out for negatives:
o -2/3, not 2/-3
o 2/3, not -2/-3
• Fractions should be entered as String objects, then split into the fraction components using String and Integer methods.
Three answers:
Kenneth
2011-06-07 04:39:24 UTC
Since we don't write the code for you, we need to see what you have done so far and what problems you are having. Please post this.
JoelKatz
2011-06-07 12:04:19 UTC
You haven't given us enough information to help you. If we try to help you based on just what you've given us, we'll wind up making it much harder for you since you'll not only have to understand the problem but will also try to understand the approach we chose to solve it. You have to do enough work so we can see how you think the problem should be solved because there is more than one way to do it and people will not always agree on which is best or easiest. You didn't even specify the language.
Bhavin Joshi
2011-06-07 11:45:26 UTC
You better post jobs on a job site instead of on Y!A


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...