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
For what show did the actor, whose star is located at 6667 Hollywood Boulevard, earn an Emmy Award for Outstanding Supporting Ac
Ilya [14]

The show’s title is China Beach, which was a television series set in a hospital during the Vietnam War. It was aired from 1988 to 2001. The actress who won a Primetime Emmy Award for Outstanding Supporting Actress in a Drama Series was Marg Helgenberger. She won in 1990 for her role as a part-time prostitute who is also a volunteer, Karen Charlene "K.C." Koloski.  


4 0
3 years ago
Read 2 more answers
Help pls. Computer basics.
telo118 [61]
Text boxes and related tools
8 0
3 years ago
Read 2 more answers
How do i protect my computer from electrical spikes
Setler [38]
I believe the answer is bloody purple poop that is the size of an extra large grilled cheese 
5 0
3 years ago
Read 2 more answers
What guidelines should you follow when adding graphics to your presentations?
Elena L [17]
B, C, and D are the correct answers.
3 0
3 years ago
Read 2 more answers
What special signal is issued periodically from an Access Point and contains the network transmission rate and service set ident
olya-2409 [2.1K]

Answer:

beacon frame  

Explanation:

Beacon frame is a management frame In computer networks, known to be in IEEE 802.11 based WLANs. These frames are transmitted periodically and they contain all the  information a station will require before it can rightly transmit a frame.  

When it comes to announcing the presence of devices in a wireless computer network (WLAN), Beacon frames are used, and they can also be used in the synchronization of the devices and services

6 0
3 years ago
Other questions:
  • Which computing component is similar to the human brain
    6·2 answers
  • which student organization helps students with career development by having them become interms to sponsor conferences?
    9·1 answer
  • Anderson uses his computer and internet link to chart the movement of his favorite 46 stocks. He buys and sells according to the
    15·1 answer
  • Which one of the following is not the name of a 20th century school composition
    14·2 answers
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    6·1 answer
  • Read the following sentence from an argumentative essay.
    11·1 answer
  • When using a presentation software you can change the size of the text to...? Increase Font size, Decrease font size, increase t
    15·2 answers
  • Identify the angle.
    12·1 answer
  • How do you remove management from your chrome book [administrator]
    12·1 answer
  • ___ is a form of electronic money that is decentralized and whose transactions are encrypted, processed, and recorded via peer-t
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!