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]
4 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]4 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
A system that organizes and controls website content and can include features that help team members work together on webpages a
BlackZzzverrR [31]

Answer:

A system that organizes and controls website content and can include features that help team members work together on webpages and other documents is referred to as a​ __groupware__ system.

Explanation:

Groupware is also know as collaborative software. This software allows multiple people to works collectively in solving a problem. It helps solving problems in an easier and in an efficient manner, because anyone in the group can solve it. It is a sort of group/team work.

3 0
3 years ago
As soon as I can, I will make a discord server for all brainly users. Would anyone like to join it once its set up? (only the di
Vesnalui [34]

Answer:me im bored ;p

5 0
4 years ago
⦁ ¿Cuáles son los recursos naturales que se utilizan en tu comunidad para generar energía eléctrica?
xxTIMURxx [149]
Turbinas de viento y turbinas de agua son utilizadas, entonces la respuesta podria ser viento y agua
7 0
3 years ago
When you call a ____________ method, it executes statements it contains and then returns a value back to the program statement t
Maksim231197 [3]

Answer:

The answer is a VOID method.

Explanation:

A void method is one that simply performs a task and then terminates.

4 0
4 years ago
Read 2 more answers
Are the ways data is represented and transmitted with computers laws of nature or laws of man?
puteri [66]
I believe the correct answer is Laws of Man
4 0
3 years ago
Other questions:
  • What does BMP stand for?
    10·2 answers
  • Because it is important not to disrupt the normal business function, joint application design (JAD) sessions should be held at a
    11·1 answer
  • Consider the eight bit signed binary number 1110 0101. Convert it to signed decimal from assuming the signed binary number is re
    5·1 answer
  • Use fuel with the _____________ rating recommended by your vehicle manufacturer. A ) Converter B) Emission C) Exhaust D) Octane
    9·2 answers
  • All conductors,buses,and connections should be considered
    13·1 answer
  • Question 4 (7 points)
    6·1 answer
  • Write the names of different types of communication.​
    15·2 answers
  • Practising some questions for board exams for class 12 python,pls help with detailed answer
    14·1 answer
  • One advantage of a PAN​
    10·2 answers
  • Why would a programmer use the logical operator or in an if statement? (5 points)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!