ajprincess
  • ajprincess
Plzzz help Write a C++ program with multiple methods to intake the two integers and do the, Addition, Subtraction, Multiplication, and Division.On your main method u hav to implement selection and repetition of the arithmetic operation
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
ajprincess
  • ajprincess
#include using namespace std; class Arithmetic { private: int answer; int numberA; int numberB; public: int addition(int numberA,int numberB); int subtraction(int numberA,int numberB); int multiplication(int numberA,int numberB); int division(int numberA,int numberB); int getNumberA(); void setNumberA(int numberA); int getNumberB(); void setNumberB(int result); int getAnswer(); void setAnswer(int result); void printOnScreen(); }; int Arithmetic::getNumberA() { return numberA; } void Arithmetic::setNumberA(int A) { numberA=A; } int Arithmetic::getNumberB() { return numberB; } void Arithmetic::setNumberB(int B) { numberB=B; } int Arithmetic::addition(int numberA,int numberB) { return (numberA+numberB); } int Arithmetic::subtraction(int numberA,int numberB) { return (numberA-numberB); } int Arithmetic::multiplication(int numberA,int numberB) { return (numberA*numberB); } int Arithmetic::division(int numberA,int numberB) { return (numberA/numberB); } int Arithmetic::getAnswer() { return answer; } void Arithmetic::setAnswer(int result) { answer=result; } void Arithmetic::printOnScreen() { cout<>choice; switch(choice) { case 1: answer=a.addition(A,B); a.setAnswer(answer); a.printOnScreen(); answer=a.addition(A,B)+A; a.setAnswer(answer); break; case 2: answer=a.subtraction(A,B); a.setAnswer(answer); break; case 3: answer=a.multiplication(A,B); a.setAnswer(answer); break; case 4: answer=a.division(A,B); a.setAnswer(answer); break; default: cout<<"Wrong choice"<
eSpeX
  • eSpeX
With the exception of this: answer=a.addition(A,B)+A; it all looks pretty good. Were you having difficulty with this code?
ajprincess
  • ajprincess
No. vat my problem is i dnt knw how to include a code that instructs the arithmetic operations to be repeated. because that's vat the question asks me to do.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

ajprincess
  • ajprincess
@eSpeX
eSpeX
  • eSpeX
You could enclose the main switch section in a while loop, this would cause it to repeat until some condition, maybe while(choice != 0). Is that what you're looking to do?
eSpeX
  • eSpeX
while(choice != 0) { cout<<"Enter the choice:\n"; cout<<"Press 1 for addition:\n"; cout<<"Press 2 for subtraction:\n"; cout<<"Press 3 for multiplication:\n"; cout<<"Press 4 for division:\n"; cout<<"Press 0 to exit:"; cin>>choice; switch(choice) { case 0: break; case 1: answer=a.addition(A,B); a.setAnswer(answer); a.printOnScreen(); answer=a.addition(A,B)+A; a.setAnswer(answer); break; case 2: answer=a.subtraction(A,B); a.setAnswer(answer); break; case 3: answer=a.multiplication(A,B); a.setAnswer(answer); break; case 4: answer=a.division(A,B); a.setAnswer(answer); break; default: cout<<"Wrong choice"<
ajprincess
  • ajprincess
No. i didn't mean this. I want the addition operation to repeat again by the insertion of single code.

Looking for something else?

Not the answer you are looking for? Search for more explanations.