0

help! trying to make a calaculator that will compute fractions! i can't get it right can someone help me

#include <iostream> using namespace std; int inputValues(int num1, int den1, int num2, int den2); int addFractions(int num1, int den1, int num2, int den2); int subFractions(int num1, int den1, int num2, int den2); int divFractions(int num1, int den1, int num2, int den2); double printFractions(int num1, int den1, int num2, int den2); int main() { char op , Q; int num1,num2,den1,den2 ,result; cout<<"Welcome to the world of fractions!!! "<<endl; cout<<"Main Menu "<<endl; cout<<"1. ADD "<<endl; cout<<"2. SUBSTRACT "<<endl; cout<<"3. MULTIPLY "<<endl; cout<<"4. DIVIDE "<<endl; cout<<"5. QUIT "<<endl; cout<<"please select on operation to compute"<<endl; cin>>op; do { switch(op) { case '+': cout<<"the number you have entered are respectivly "<<num1<<den1<<num2<<den2<<endl; cin>>num1>>num2>>den1>>den2; cout<< "the result of the operation is " <<num1<<"/"<<den1<<" + "<<num2<<"/"<<den2<<"="<< result<<endl; result = addFractions( num1, den1, num2 , den2); break; case '-': cout<<"the number you have entered are respectivly "<<num1<<den1<<num2<<den2<<endl; cin>>num1>>num2>>den1>>den2; cout<< "the result of the operation is " <<num1<<"/"<<den1<<" - "<<num2<<"/"<<den2<<"="<< result<<endl; result = subFractions(num1, den1 , num2 ,den2); break; } }while (op != 'Q'); return 0; } int inputValues(int&, int&, int&, int&) { int num1, den1, num2, den2; return num1 , den1, num2, den2 ; } int addFractions(int num1, int den1, int num2, int den2) { int result ; result = (num1/den1) + (num2/den2); return result; } int subFractions(int num1, int den1, int num2, int den2) { int result; return result; result = (num1/den1) - (num2/den2); } int divFractions(int num1, int den1, int num2, int den2) { int result; return result; result = (num1/den1) / (num2/den2); }

16th Oct 2017, 7:48 PM
komla
4 ответов
0
please use code playground.
16th Oct 2017, 7:58 PM
Cain Eviatar
Cain Eviatar - avatar
0
Thanks
16th Oct 2017, 8:24 PM
komla
0
u must switch the last 2 lines. the 'return result' must be the last sentence in ur method. if that's not the Problem, please put the link of the code (code playground) instead of the code itself and explain to me what do u mean with fractions
16th Oct 2017, 8:25 PM
Humberto da Silva Neto
Humberto da Silva Neto - avatar
0
Thanks
16th Oct 2017, 9:14 PM
komla