This is not needed, but a curiosity with that program. Would you have any clue a
ID: 3619169 • Letter: T
Question
This is not needed, but a curiosity with that program. Would you have any clue as how to reduce the fractions tolowest terms with a simple math problem? I have been going overthat one in my head, thinking that it would take at least a fewsteps and some if statements, which honestly, is not worth doing atthis point. Would you have any clue as how to reduce the fractions tolowest terms with a simple math problem? I have been going overthat one in my head, thinking that it would take at least a fewsteps and some if statements, which honestly, is not worth doing atthis point.Explanation / Answer
x.P5lor="red">please rate - thanks this is added to this mornings post. note the move of the output, from 4 times in the switch, to once outside the switch make a decision about negative numerators. because right now -1/2 - #include #include #include #include using namespace std; //prototype of the functions bool getnum(int&); int gcd(int,int); char menu(); void addFractions( int a1, int b1, int a2, int b2, int & num, int & den ); void subtractFractions( int a1, int b1, int a2, int b2, int & num, int & den ); void multiplyFractions( int a1, int b1, int a2, int b2, int & num, int & den ); void divideFractions( int a1, int b1, int a2, int b2, int & num, int & den ); int main() // function main begins program execution { int a1, b1, a2, b2, num, den, exit,factor; bool good1=false,good2=false,num1found=false,num2found=false,inputerror; char ch = menu(); while (ch!='X') { //Try block checks for input validation //throws if exception occured do { try {if(!good1) {if(!num1found) {// prompt and read the input from the user cout > a1; inputerror=getnum(a1); if(inputerror) { string s="valid number not entered"; throw s; } num1found=true; } // prompt and read the input from the user cout > b1; inputerror=getnum(b1); if(inputerror) { string s="valid number not entered"; throw s; } // validate the denominator if ( b1 == 0 ) throw b1; else if (b1 a2; inputerror=getnum(a2); if(inputerror) { string s="valid number not entered"; throw s; } num2found=true; } // prompt and read input from the user cout > b2; inputerror=getnum(b2); if(inputerror) { string s="valid number not entered"; throw s; } // validate the denominator if ( b2 == 0 ) throw b2; else if (b2Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.