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
ANYONE WANNA FRIEND ME ON DISCORD ゴRose joestarゴ#2088
Sergeeva-Olga [200]

JOJO fan!?!!?!??!?!?!!?!?

6 0
3 years ago
Isabel and Jared work for the same company but in different departments. Their workstations are both part of the company's compu
Nina [5.8K]

Network access limitations implemented from their local IT Department

3 0
3 years ago
Read 2 more answers
Worksheet cells can only be moved one at a time.
Vadim26 [7]
If the question is true or false, it is <u>false</u>. Also assuming you are referring to Excel or similar spreadsheet programs.
4 0
2 years ago
onsider a file system on a disk that has both logical and physical block sizes of 512 bytes. assume that the information about e
anygoal [31]

For three disk allocation strategies (contiguous, linked, and indexed),

in this case, the  physical blocks must be read from the disk are 1,4 and 2 respectively.

In the disk, every block has a sequential number. The majority of disks today do logical I/O in hardware. Physical I/O is seldom ever required of operating systems today.

File access uses virtual I/O. Similar to disk logical I/O is disk virtual I/O. The distinction is that with virtual I/O, as opposed to physical I/O, the blocks that make up a file are

You could want to transfer from virtual block 10 to virtual block 4 in a contiguous allocation. Since the file is contiguous and you are at logical block 10 + Z, block four can be accessed by reading logical block 4 + Z. Without any intermediaries, that can be done directly.

Each block in the linked structure has 511 bytes of data and one byte that serves as an offset to the following block.

Read the first block, determine the offset to the second block, read the second block, determine the offset to the fourth block, and then read the fourth block in order to gain access to the fourth block.

If blocks are numbered from 1 to 10, then then is the "4" correct. The remainder of the solutions, however, make the assumption that block numbering begins at 0, using division to obtain offsets.

Assume there is a contiguous index for the indexed way of allocating files. Once more, it is assumed that each offset in the index is one byte in size.

Let's say that Z serves as the index's origin. Then, the byte at block Z + 3 DIV 512 and the offset at 3 MOD 512 (3 = 4 - 1) make up the entry for block 4 (numbered 1 to 4).

You must read the index and the data block in order to locate the block (2 reads).

To learn more about disk allocation strategies click here:

brainly.com/question/15083707

#SPJ4

4 0
1 year ago
Something which has a special meaning in a python programming language is termed as what?
Elis [28]

Answer:

Explanation:

A Dutch programmer named Guido van Rossum made Python in 1991.This also means Python is slower than a compiled language like C, because it to avoid changing the language to make it better until they have a lot of things to change.

Python is an interpreted, high-level and general-purpose programming language. Created by  This compact modularity has made it particularly popular as a means of  a rough transcription from another programming language is called unpythonic. It has fewer syntactic exceptions and special cases than C or Pascal.

plz mark as brainliest

6 0
3 years ago
Other questions:
  • Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
    14·1 answer
  • What is cyber stalking and how does it work?
    7·2 answers
  • Violations of security policies are considered to be a(n) __________ issue upon which proper disciplinary actions must be taken.
    7·1 answer
  • As part of a team, you are assigned to create a financial report. One of your tasks is to put the pieces together as other team
    5·1 answer
  • Images are available in many formats, such as tif, bmp, gif, jpeg, and ____.
    5·1 answer
  • How are satellite radio, Internet radio, and podcasting different?
    11·1 answer
  • Help it's the last question quickkk​
    7·1 answer
  • Select the correct answer.
    9·1 answer
  • Tommy loves taking care of homing pigeons. He sent a note to his crush who lives 24.0 km away from his house. These birds fly at
    9·1 answer
  • 6. Write a C++ program to print the largest three elements in an array. <br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!