Solved
Need some help with functions to do arithmetic
Posted on 2003-03-06
I'm just in the planning stages of this program, so I just need to know how to do this. I don't know to know any actual code for it...
This is my assignment: Write four functions, one for each of the operations on fractions: addition, subtraction, multiplication, and division. If the denominator of a result will be zero, the main program should display a message, and NOT call the functions.
Each function has six parameters. The first four: numerator of fraction one, denominator of fraction one, numerator of fraction two, and denominator of fraction two are passed by value.
This is an example of how my program should work:
An example for the function to add two fractions is:
Do you wish to do arithmetic on two fractions? (Y or N): Y
Enter the numerator and denominator of the first fraction: 4 5
Enter the numerator and denominator of the second fraction: 2 6
4/5 + 2/6 = 34/30 = 17/15
4/5 - 2/6 = 14/30 = 7/15
4/5 * 2/6 = 8/30 = 4/15
4/5 / 2/6 = 24/10 = 12/5
Right now I just need help in determing what steps I have to take in writing the code to perform the actual arithmetic operations. Could someone please give me a walkthrough of what I'll have to do? I need it for my project but I also need it because I have no idea how to do it either. I especially don't know how to deal with the fractions. Thanks -JT