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
Practising some questions for board exams for class 12 python,pls help with detailed answer
poizon [28]
I do t know the answer to this but i think tou can firger it iut food luck
3 0
3 years ago
Write a definition in your own words for GUI. Do not copy and paste please.
Goryan [66]

Answer:

something where you can interact with and it takes you somewhere. for example, you click g00gle and it takes you to g000gle.

Explanation:

8 0
3 years ago
Read 2 more answers
What are the five types of alignment in Word?
Basile [38]
There are four types of alignment in word.
Left-aligned text
Right-aligned text
Center-aligned text
Justified text
6 0
3 years ago
Read 2 more answers
In the ADT graph, the method addEdge has efficiency
Tanzania [10]

Answer:

B.O(n).

Explanation:

In an ADT graph the method addEdge uses an Array of list.So in the worst case and the worst will be when the list already has n elements in it.

So to add an edge we have to iterate over the list upto nth element and then add the edge after that.So it has to travel over n elements.

So we can say that the answer is O(n).

3 0
3 years ago
Which routine is configured to execute first when the program runs?
tester [92]
It's D because of ok
4 0
3 years ago
Other questions:
  • Charles sends Julia text messages every morning insulting her appearance and threatening to hurt her. He writes unflattering des
    5·2 answers
  • Page _____ refers to whether a page is laid out vertically or horizontally.
    12·1 answer
  • Would you recommend the 4a generations of computers to a friend
    5·1 answer
  • Which is the biggest known issue specific to satellite Internet connections?
    13·2 answers
  • Once you create a slide show, it is not easy to rearrange things, so you should plan your presentation ahead of time.
    14·1 answer
  • Which of the following components helps to limit the front-to-back movement of the crankshaft? 
    9·2 answers
  • A global project called One Laptop per Child is attempting to distribute low-cost laptop computers to children in developing cou
    10·1 answer
  • Mary is working on joining of a new domain tree to an existing forest, but before starting the process, she should have at least
    7·1 answer
  • Which group scope can be used to assign permissions to resources only in the domain in which the group is created
    12·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of cust
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!