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
Explain three specific &amp; major security threats to internet users. In each case, address whether or not the vulnerabilities
kherson [118]

Answer:

See explaination

Explanation:

We already know that people all over the world are using the internet to communicate with each other to store their personal data, for the entrainment working in internet, doing online shopping and a lot of things. The user can faced with many threats. These threats are of different form.

The listed and explained below are some of the threats;

a) Compromised browser:-

Most popular browser are targeted and any security flaws exploited immediately. Criminals uses the flaws to gain access to sensitive document and shadow users browsing activity.

Phishing:-

Phishing is simply referring to the spam email or websites. Most times it is used to steal ones data, identity and funds. It looks genuine, this is what makes it hard to detect .

Poisoned websites:-

These are the fake link with hidden malware where the malware creator create a juicy news /video link which attract the user but the destination affect the PCs and the PC give a big virus alert and then compelled a visitor to be aware of the malware.

Misused social media sites:- These are often used in work place these are misused to spread Trojans and malware User download file and put the corporate network at risk .

These threats are not meaningful to the internet of Things (IOT) but there are different things like if you have a CCTV camera and it is connected to internet so by the threads anyone can take control over the cameras it can shut down the camera delete the recording of the camera and other things. There are the other threats.

7 0
3 years ago
The _____ component of a decision support system (DSS) includes mathematical and statistical models that, along with the databas
Ira Lisetskai [31]
Model Base. Hope it helps
5 0
3 years ago
What do you think about the use the top song on a video you are creating
stepladder [879]

Hiya!


Using a popular song in a video your making is most definitely going to attract more viewers. It's all about making the video appeal to the person.

^Hope this helps

3 0
3 years ago
Read 2 more answers
According to chronology, arrange the steps that you need to take during the installation of a ram stick?
MAXImum [283]

Answer:

first off you need to take of the screws make sure its unpluged and you open up to see the mother bored

Explanation:

6 0
3 years ago
Physical activity such as sports or even a brisk walk can help reduce
ycow [4]
Physical activity could help reduce the chance ofheart disease
4 0
3 years ago
Read 2 more answers
Other questions:
  • Tower defense is included under which genre of game
    15·2 answers
  • Why is it important to have regular maintenance and care of your office equipment?
    5·1 answer
  • Refers to the programs or instructions used to tell the computer hardware what to do.
    8·1 answer
  • What X coordinate does the center of a game begin at?
    9·1 answer
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    5·1 answer
  • Tara is creating a presentation for her science project about volcanoes. She added different animations to every slide for empha
    12·1 answer
  • Which line of code will find the first occurrence of a three in an array?
    5·2 answers
  • Edhesive 9.3 code practice
    11·1 answer
  • HELP MY TABLET KEEPS ON REBOOTING I TRIED TO FACTORY RESET BUT IT KEEPS ON REBOOTING
    12·2 answers
  • What can you think of as a box or container that holds a value and has a label?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!