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
Consider an implementation of the instruction set architecture P1 has a clock rate of 4.8 GHz and CPIs (Cycles Per Instruction)
Anestetic [448]

Answer:

a) 3.3

b) 3

Explanation:

1)

As we know ,

CPI = sum of ( instructions× clock cycle)

     = 50%(1) + 30%(4) + 20%(8)

    = 50% + 120% + 160%

    = 330%

    = \frac{330}{100} = 3.3

⇒CPI = 3.3

2)

Let a = number of cycles on average

As given,

a 10% improvement in performance of P1,

⇒New CPI = 3

⇒3 = 50% + 30% (x) + 20%(8)

⇒3 = 50% + 30% (x) + 160%

⇒3 = 210% + 30%(x)

⇒3 = 2.1 + 0.3x

⇒3 - 2.1 = 0.3x

⇒0.9 = 0.3x

⇒x = \frac{0.9}{0.3} = 3

⇒x = 3

∴ we get

Number of cycles on average = 3

6 0
3 years ago
Please convert 5AE into decimal​ fast
MaRussiya [10]

Answer:

it could be decimal or hexadecimal

7 0
4 years ago
I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
S_A_V [24]

Answer:

Working with text in presentation programs is similar to working with text in other application, audience size influences font size, and font size and font color can be changed in presentations.

6 0
4 years ago
Read 2 more answers
how can cindy collaborate with mallory in order for cindy to be able to decrypt all subsequent encrypted messages that are sent
Olenka [21]

Cryptography, like digital signatures, is used to accomplish nonrepudiation, which also includes services for authentication, auditing, and logging.

Digital signatures in online transactions make assurance that a party cannot later dispute the sending of information or the validity of its signature. Alice can encrypt the communication using her own Private Key. As a result, only her public key, which she is aware Bob (and everyone else) has access to, may be used to decrypt her message. Bob receives the message, and he uses Alice's public key to decrypt it. Secret key cryptography (symmetric encryption): To encrypt and decrypt given messages, both the sender and the receiver must use the same key.

Learn more about information here-

brainly.com/question/15709585

#SPJ4

6 0
1 year ago
Which of the following describes the difference in light intensity between the brightest white and the darkest black that can be
Y_Kistochka [10]

Answer:

a. Contrast ratio

Explanation:

According to my research on LCD technology, I can say that based on the information provided within the question the term being described by the question is called Contrast Ratio. This is used in all TV's and monitors, since it controls the blacks and white color gradient of the images on the TV's and monitors.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Other questions:
  • Create a procedure named FindLargest that receives two parameters: a pointer to a signed doubleword array, and a count of the ar
    13·1 answer
  • Media convergence is the result of the integration of the different media technologies. Please select the best answer from the c
    13·2 answers
  • Html version ____ added support for style sheets to give web designers greater control over page layout and appearance.
    10·1 answer
  • According to Google data, among consumers who conduct a local search on their smartphone, how many then visit a store within a d
    7·1 answer
  • ASCII contains codes for most of the languages in use today.<br><br> True or False
    12·1 answer
  • In what ways are hardware and software different? in what ways are the the same?
    10·2 answers
  • A domain name is used to: *
    15·1 answer
  • Types of network model​
    11·1 answer
  • PLEASE HURRY!!<br> Look at the image below
    14·1 answer
  • What does Iamo mean? i keep on hearing it and idk what it means
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!