Im writing a fraction calculator program I finished the program but keep getting an error on the do while function. can someone help
heres the program
heres the program
Code:
#include <iostream> #include <iomanip> #include <cmath> using namespace std; // Internal storage int choice; int num1; int denom1; int num2; int denom2; int calcden; int calcnum; void menuFunction(void) { int denominator1, numerator1,denominator2, numerator2; char operation; cout<<"This program will agther your input, and perform mathematical operations on fractions. you will be prompted to enter a denominator and numerator for two fractions, and hen will be asked to enter an operation you wish to perform"<<endl; cout<<"Please enter the first numerator"<<endl; cin>>numerator1; cout<<"Please enter the first denominator"<<endl; cin>>denominator1; cout<<"Please enter the second numerator"<<endl; cin>>numerator1; cout<<"Please enter the second denominator"<<endl; cin>>denominator2; cout<<"You may choose aadition (+), subtraction (-), multiplication (*) or division (/)...please choose an operation:"<<endl; cin>>operation; //perform error checking, call other functions, etc... } void add() { calcnum=num1*denom2 + denom1*num2; calcden=denom1*denom2; } void subtract() { calcnum=num1*denom2-(denom1*num2); calcden=calcden=denom1*denom2; } void multiply() { calcnum= num1*num2; calcden=denom1 * denom2; } void divide() { calcnum= num1*denom2; calcden=denom1 * num2; } void exit() { cout<<"Have a nice day. "; } void main() { do while(choice!='5') { cout<<"Enter a number from the menu: "; cin >> choice; menu(); cout<< "Enter the firts numerator: "; cin >>num1; cout<< "Enter the firts denomerator: "; cin>>denom1; cout<< "Enter the second numerator: "; cin>>num2; cout<< "Enter the second numerator: "; cin>>denom2; cout<<calcnum<<" /"<<calcden; } }
Comment