Question: CAN YOU PLEASE GUIDE ME WHY I AM GETTING THIS ERROR AND HELP FIX THE CODE Instructions * * ( Fraction calculator ) * *
CAN YOU PLEASE GUIDE ME WHY I AM GETTING THIS ERROR AND HELP FIX THE CODE
Instructions
Fraction calculator Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form ab in which a and b are integers and b Your program must be menu driven, allowing the user to select the operation or and input the numerator and denominator of each fraction. Furthermore, your program must consist of at least the following functions:
Function menu: This function informs the user about the programs purpose, explains how to enter data, and allows the user to select the operation.
Function addFractions: This function takes as input four integers representing the numerators and denominators of two fractions, adds the fractions, and returns the numerator and denominator of the result. Notice that this function has a total of six parameters.
Function subtractFractions: This function takes as input four integers representing the numerators and denominators of two fractions, subtracts the fractions, and returns the numerator and denominator of the result. Notice that this function has a total of six parameters.
Function multiplyFractions: This function takes as input four integers representing the numerators and denominators of two fractions, multiplies the fractions, and returns the numerators and denominators of the result. Notice that this function has a total of six parameters.
Function divideFractions: This function takes as input four integers representing the numerators and denominators of two fractions, divides the fractions, and returns the numerator and denominator of the result. Notice that this function has a total of six parameters. Some sample outputs are:
Your answer need not be in the lowest terms.
CODE#
#include
using namespace std;
void menu
cout "This program lets you perform arithmetic operations on fractions." endl;
cout "Enter the numerator and denominator of each fraction, separated by a space." endl;
cout To add two fractions, enter endl;
cout To subtract two fractions, enter endl;
cout To multiply two fractions, enter endl;
cout To divide two fractions, enter endl;
cout To quit the program, enter q endl;
void addFractionsint num int den int num int den int &num, int &den
num num den num den;
den den den;
void subtractFractionsint num int den int num int den int &num, int &den
num num den num den;
den den den;
void multiplyFractionsint num int den int num int den int &num, int &den
num num num;
den den den;
void divideFractionsint num int den int num int den int &num, int &den
num num den;
den den num;
int gcdint a int b
while b
int temp a;
a b;
b temp b;
return a;
void simplifyFractionint &num, int &den
int gcdvalue gcdnum den;
num gcdvalue;
den gcdvalue;
int main
menu;
while true
char operation;
cout "Enter an operation or q to quit: ;
cin operation;
if operation q
break;
else if operation operation operation operation
int num den num den;
cout "Enter the first fraction: ;
cin num den;
cout "Enter the second fraction: ;
cin num den;
int num, den;
if operation
addFractionsnum den num den num, den;
else if operation
subtractFractionsnum den num den num, den;
else if operation
multiplyFractionsnum den num den num, den;
else if operation
divideFractionsnum den num den num, den;
simplifyFractionnum den;
cout num den operation num den num den endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
