1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
salantis [7]
3 years ago
6

Write a calculator program that keep reading operations and double numbers from user, and print the result based on the chosen o

peration using while loop. The loop must stop if the user enters Q letter.
NOTE: no need to write two classes.

Typical run of the program:

Enter an operation(+,-,*,/), Q to quit: +

Enter your first number: 6

Enter your second number: 5

Result= 11.0

Enter an operation(+,-,*,/), Q to quit: *

Enter your first number: 5

Enter your second number: 5

Result= 25.0

Enter an operation(+,-,*,/), Q to quit: q

You calculator has been ended!
Computers and Technology
1 answer:
AveGali [126]3 years ago
5 0

Answer:

 #include <iostream>

using namespace std;

int main()

{

   char opt;

   double num1,num2;

   cout<<"Enter an operation(+,-,*,/), Q to quit: ";

   cin>>opt;

  while(opt != 'Q'){

      cout<<"\nEnter your first number: ";

      cin>>num1;

      cout<<"\nEnter your second number: ";

      cin>>num2;

      if(opt == '+'){

          cout<<"Result = "<<num1+num2<<endl;

      }else if(opt == '-'){

           cout<<"Result = "<<num1-num2<<endl;

      }else if(opt == '*'){

           cout<<"Result = "<<num1*num2<<endl;

      }else if(opt == '/'){

           cout<<"Result = "<<num1/num2<<endl;

      }

      cout<<"Enter an operation(+,-,*,/), Q to quit: ";

      cin>>opt;

  }

  return 0;

}

Explanation:

First, include the library iostream, it allows to use the input/output instruction.

Create the main function and declare the variables.

Then print the message on the screen using cout instruction.

cin instruction is used to store the value into the variable.

then, take a while and check the condition if the value enters by the user is 'Q' or not. if true then enter the while otherwise exit.

after that, store the number enter by the user in the variables and then take the if-else statement for matching the operation enter by the user if match true then do the match operation.

This process continues until the user enters the value 'Q'.

if the user enters the 'Q'  then condition false and exit the program.

You might be interested in
Tina reported a safety hazard at her workplace to OSHA. Representatives from OSHA came to her work and inspected the issue, then
earnstyle [38]

Answer:

Knowledge of hazardous workspace conditions

6 0
2 years ago
Your welcome 95 points gg
STatiana [176]

Answer:

tysm :))

Explanation:

have a great day

4 0
3 years ago
Read 2 more answers
Jake was working on an essay for his English class on a stormy Sunday afternoon. Before he could save his document, a big strike
matrenka [14]

Maybe in atosave, Computers mostly save what your working on :3

8 0
3 years ago
Can you withdraw from courses in top hat?
ad-work [718]

Answer:

Yes, but this must be done before the withdraw deadline

Explanation:

TopHat is an online learning platform. Students register for courses and if they decide not to continue with a course for reasons best known to them, they are allowed a time period usually one to two weeks to drop the courses. They are then reimbursed the fee for that particular course.

But if that time period elapses and they drop the course, that is considered a withdrawal that is not accepted and which no provisions for reimbursements are made.

7 0
2 years ago
How do I fix this on my HiSense Roku tv this is on Xfinity Stream Beta the error number is -500
yawa3891 [41]

Answer:

it is something that you have to call your nearest xfinity store

i had the same problem but got it fixed

Explanation:

7 0
2 years ago
Read 2 more answers
Other questions:
  • What is microsoft excel
    12·1 answer
  • Questions 1 )When does a spring tide take place?
    14·2 answers
  • An administrator has noticed that GPO containing new update settings has not yet applied to one of the computers on the network.
    5·1 answer
  • Without protocols the information sent and received through the Internet would never reach its intended target and even if it di
    6·1 answer
  • Which principle of CSR requires that a business state facts fully and accurately?
    8·1 answer
  • An application needs to calculate sales tax for purchases. You decide to simplify the code by putting the sales tax calculation
    9·1 answer
  • Discuss the different types of user-friendly interfaces and the types of users who typically use each.
    12·1 answer
  • Of the following online activities, identify the TWO that are most likely to be affected by bandwidth quality
    11·1 answer
  • Running the Disk Cleanup utility is a quick way to ________. Group of answer choices defrag your hard drive remove spyware progr
    10·1 answer
  • quiz Flavio visits a local coffee shop on his way to school and accesses its free Wi-Fi. When he first connects, a screen appear
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!