Help writing this C++ program


Having trouble with writing this any help would be appreciated, Im not very good at writing code so any help will be appreciated Thanks.

Write a program that inputs two fractions (a numerator and a denominator for each). The program should work properly for all fractions, except those that have a zero in either denominator. If the user enters 0 in a denominator, give an error message and exit the program. You will then use these two fractions to do the following:

Add the two fractions together and give the resulting fraction and the decimal equivalent. Remember that you can only add fractions that have the same denominator and for this lab you may just multiple the two denominator together (make sure you appropriately multiply the numerators), to give a common denominator, without worrying about the least common denominator. If the two fractions that were entered were 9/13 and 7/12 the output would be shown as both 199/156 and 1.2756.
Multiply the two fractions together and give the resulting fraction and the decimal equivalent. If the two fractions that were entered were 2/9 and 6/3 the output would be 12/27 and 0.4444

closed account (Dy7SLyTq)
hmmmm... sounds like homework
agreed
Interesting assignment you got there. Seems challenging enough; the only thing I don't understand about it is how you are going to go about producing the fractions. The only I could think of is to get each integer one at a time from the user, but that seems rather boring for such a task.

E: getch() and stringstream :D. OH yea that could work. That way the user can just enter 3/4 instead of:

"..enter numerator " 3... "...enter denominator "4
Last edited on
Topic archived. No new replies allowed.