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
C. There are two types of computer on the basis of size. true or false​
Veronika [31]

Answer:

False

Explanation:

Different factors, such as processing power, information processing, and the component (CPU) utilised in computers, are used to classify computers. Micro-computers, Mini-computers, Main-frame computers, and Super-computers are divided into four categories based on the components utilised and functionality of the computers.

4 0
3 years ago
Interactive sites where users write about personal topics and comment to a threaded discussion are called?
larisa [96]

Answer:

C. forums

Explanation:

Forums are internet sites where users can meet to discuss different topics through the use of messages thereby forming chat rooms. An internet forum can be in form of a question and answer site. Most websites have internet forums where users can meet and discuss or ask questions. Sometimes there may be moderators that ensure that the posted messages are acceptable based on guidelines.

4 0
3 years ago
Which file extension does GIMP save a file in (before saving it in a file format that can be used by other programs)?
andreev551 [17]
Portable document format
8 0
3 years ago
Why is ssh preferred over telnet for remote connections?
jarptica [38.1K]
Telnet conversations are not encrypted, whereas ssh conversations are, so ssh is secured against eavesdropping.
3 0
3 years ago
Access to a computer can be controlled using a ____ password.
slamgirl [31]
Yes it can be control by a USER ( administrator and having a MASTER password) 
8 0
3 years ago
Other questions:
  • "HotelExp” is a 3-D range name applied to the workbook shown.
    12·1 answer
  • Select the correct answer.
    6·1 answer
  • Which options correctly describe Andrew's job role?
    6·1 answer
  • A food web is shown below. In this food web, energy is transferred directly from the to the
    11·1 answer
  • What part of a file name does windows use to know which application to open to manage the file?
    13·2 answers
  • How to drive more website traffic?
    11·1 answer
  • Having a conversation with someone using a cellular phone is an example of _________ transmission. simplex full-duplex half-dupl
    11·1 answer
  • What specific record type is found in every zone and contains information that identifies the server primarily responsible for t
    10·1 answer
  • While there are a some exceptions such as an if-statement, Scheme has one primary syntax () a) True b) False
    14·1 answer
  • Select the correct answer.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!