Hi Guys, I am supposed to write a program which can perform simple fraction arithmetic, however the answer is supposed to come out as an unreduced form.
EG: 3/5 + 1/5 = 20/25
if the result is improper then it can either be a whole number or a mixed number (my choice)
if the problem is un-calculable then an error message is the result.
Below is what I have written so far. I just need to figure out how to get the problem to result in an unreduced form.
Any help would be encouraged. Thank you
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int numerator1, numerator2;
int denominator1, denominator2;
int answer1;
Answer is int. Int is throwing out everything after the dot(e.g. when result is 25.99345, then result would be just 25). Change it to double.
Also, wrap your code in [.code][./code] tags next time(without dots, of course).
If you want to receive x/y notation, then you shouldn't calculate answer. It won't help you anyway :)