MY ASSIGNMENT:
Write a program that works with fractions. Your program should be able to add, subtract, multiply, and divide two fractions. Specifically, your program must request two fractions from the user, getting the numerator and denominator separately for each fraction, and the operation to perform (add, subtract, multiply, or divide). Your program will then compute the resulting fraction, keeping the numerator and denominator separate, and output the result. The resulting fraction must be simplified. For example, (4 / 6) should be displayed as (2 / 3), and (8 / 8) should be displayed as (1 / 1). You will need to use the GCD function from Problem 1 to do this simplification, so be sure to test it thoroughly before using it here.
You must compute the resulting fraction using fraction-based math (working with numerators and denominators). Do not simply convert the fractions to double values (like 1.5), do the math, and convert back to a fraction. There are numerous resources on the Internet if you need a refresher on how to add, subtract, multiply, and divide fractions.
_______________________________________________________________________________________
This is what I have so far. I kinda need some help on this. Thank You!!
#include <iostream>
using namespace std;
int fraction_subtract (int x1, int y1, int x2, int y2);
int fraction_add (int x1, int y1, int x2, int y2);
int fraction_multiply (int x1, int y1, int x2, int y2);
int fraction_divide (int x1, int y1, int x2, int y2);
int main()
{
int x1, y1, x2, y2;
cout << "Enter a number for x1 and y1: ";
cin >> x1 >> y1;
cout << "Enter a number for x2 and y2: ";
cin >> x2 >> y2;
return 0;
}
int fraction_subtract (int x1, int y1, int x2, int y2)
{
int denom, num, frac;
denom = y1 * y2;
num = ((x2 * -1) * y1) - ((x1 * -1) * y2);
frac = (num, denom);
return frac;
}