Question:
Help me write a c++ program?
anonymous
2011-04-06 10:46:48 UTC
Write a well-documented C++ program to create the equivalent of a four-function
calculator. The program should request the user to enter a number, an operator
(data type - char), and another number. It should then carry out the specified
arithmetic operation: adding, subtracting, multiplying, or dividing the two numbers.
(Hint: use a switch statement to select the operation). For division, if the
denominator is zero, output an appropriate message.

Finally, the program should display the result in an algebraic equation format.
For examples,

num operation num = answer

5 + 6 = 11
12 / 3 = 4
Three answers:
despotovski01
2011-04-06 11:06:40 UTC
Maybe this tutorials would help you:

http://www.youtube.com/watch?v=uZdMigh3Tp8

http://www.youtube.com/watch?v=rCWzFw8cHrA&feature=related

http://www.youtube.com/watch?v=fpqIZz6TvNA&feature=related
?
2017-02-25 16:07:17 UTC
#comprise int considerable() int c = 0; int a = 5678; together as(c < 5) c +=a million; if(c==a million) printf("np.c.d", a); if(c==2) printf("np.Cd", a-5000); if(c==3) printf("np.Cd", a-5600); if(c==4) printf("npercentd", a-5670); which could do it, yet i does not turn this in.
?
2011-04-06 11:07:29 UTC
// I Have tried my best .......Now Run This Code........May Be it Is your desired Code.........thanks



#include

#include

using namespace std;

int main()

{

double num;

double num2;

char choice;

for (;;){

do {

cout<<"Please choose an option by entering the number, press q to quit\n";

cout<<"1 - Addition\n";

cout<<"2 - Subtraction\n";

cout<<"3 - Division\n";

cout<<"4 - Multiplication\n";

cin>>choice;

} while ( choice < '1' || choice > '4' && choice != 'q');

if (choice == 'q') break;

switch (choice) {

case '1':

cout<<"Please enter a number\n";

cin>>num;

cout<<"Another number to be added\n";

cin>>num2;

cout<
cout<<"\n";

break;

case '2':

cout<<"Please enter a number\n";

cin>>num;

cout<<"Another number to be subtracted\n";

cin>>num2;

cout<
cout<<"\n";

break;

case '3':

cout<<"Please enter a number\n";

cin>>num;

cout<<"Another one to be divided\n";

cin>>num2;

if(num2==0)

{

cout<<"Sorry,Number is not Divided By Zero ";

}

else if(num>num2)

{

cout<
}

else

{

cout<
}

cout<<"\n";

break;

case '4':

cout<<"Please enter a number\n";

cin>>num;

cout<<"Another one to be multiplied\n";

cin>>num2;

cout<
cout<<"\n";

break;

default:

cout<<"That is not an option";

}

}

return 0;

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...