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
emmasim [6.3K]
4 years ago
13

Write a calculator program using a switch statement that: a) Prompts the user to enter two numbers b) Prompts the user to select

between the four arithmetic operations using a choice from 1-4; for example, prompt the user with: "Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide)" c) Calculates the result of performing the selected operation on the numbers, and d) Displays the answer on the screen (15 pts)
Computers and Technology
1 answer:
dlinn [17]4 years ago
5 0

Answer:

// calculator program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int x,y;

int ch;

   cout<<"Enter 1st number:";

   // read first number

   cin>>x;

   cout<<"Enter 2nd number:";

   // read second number

   cin>>y;

   cout<<"Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide):";

   // read choice

   cin>>ch;

   switch(ch)

   {

       // if choice is 1, find Addition

       case 1:

       cout<<"Addition of two numbers is:"<<(x+y)<<endl;

       break;

       // if choice is 2, find subtraction

       case 2:

       cout<<"Subtract the second from the first is:"<<(x-y)<<endl;

       break;

       // if choice is 3, find multiplication

       case 3:

       cout<<"Multiplication of two numbers is:"<<(x*y)<<endl;

       break;

       // if choice is 4, find division

       case 4:

       cout<<"Division the first by the second is:"<<(x/y)<<endl;

       break;

       // if choice is other

       default:

       cout<<"Wrong choice:"<<endl;

       break;

   }

return 0;

}

Explanation:

Read two numbers from user.Then read the choice of operation from user.If choice is 1, then print the Addition of both numbers.If choice is 2, then print the subtraction. If the choice is 3, then print the multiplication.If choice is 4, then print the  division.If choice is other than these, then print wrong choice.

Output:

Enter 1st number:10                                                                                                      

Enter 2nd number:2                                                                                                      

Choose 1) for add, 2) for subtract, 3) for multiply or 4) for divide):3                                                    

Multiplication of two numbers is:20

You might be interested in
When you buy software, you then own it and can do anything you’d like with it, including giving it to friends to install on thei
luda_lava [24]
No. When you purchase software, it is usually distributed under a license that only lets you do certain things with it. It is usually only for personal use, but other times the manufacturers of the software will allow you to freely redistribute it.
3 0
3 years ago
What is software??????​??????????????????
larisa [96]

Answer:

<h3>Defination of Software :- </h3>

  • software, instructions that tell a computer what to do. Software comprises the entire set of programs, procedures, and routines associated with the operation of a computer system. The term was coined to differentiate these instructions from hardware.
  • The physical components of a computer system.

Explanation:

<h3>Hope this helps you dear ✌️</h3><h2>Carry on learning !! </h2>

4 0
3 years ago
Read 2 more answers
Thomas has decided to key an agenda for the FBLA meeting using a column format. What is recommended to guide the reader’s eye an
astra-53 [7]

Incomplete question. The full question reads;

Q. Thomas has decided to key an agenda for the FBLA meeting using a column format. What is recommended to guide the reader's eye and control the left-to-right flow of text?

Answer choices:

  • table feature
  • dot leader tab
  • left alignment tool
  • double space

Answer:

<u>dot leader tab</u>

Explanation:

Indeed, Thomas could use the dot leader tab on MS word to guide the reader's eye and control the left-to-right flow of the text so the reader can note the agenda.

For example, below is a typical way the dot leader tab would look like on a document:

............... Agenda 1

............... Agenda 2

............... Agenda 3

7 0
4 years ago
During the first six months of his job, Enrique's boss gave him weekly feedback about his performance. What component of effecti
Nat2105 [25]
Being direct I think because Enrique’s boss is being direct about his work and making sure he does his job. The other options don’t sound right
8 0
3 years ago
What makes Darth Vader's sound so sinister, menacing and evil?
olganol [36]

Answer:

The volume, special effects, and the content of the speech.

Explanation:

The volume and special effects make all video productions's tone clearer. The words that Darth Vader speaks also adds to his "bad guy" character.

3 0
4 years ago
Read 2 more answers
Other questions:
  • ________ viruses are often transmitted by a flash drive left in a usb port.
    8·1 answer
  • Public static void prefixmerge(customer[] list1, customer[] list2, customer[] result {
    6·1 answer
  • What is the meaning of website cookies? brief explanation ​
    9·2 answers
  • Because of Moore's Law, widely-used encryption programs currently employed by banks and ecommerce sites are now easily penetrate
    11·1 answer
  • To always see the header row with scrolling through long worksheets, you would use the ______ command.
    8·1 answer
  • When you create new document, you have the option to create a blank document or a predifined
    7·1 answer
  • How do you detect my account for brainly?
    14·1 answer
  • What is the main difference between weathering, erosion and leaching​
    9·1 answer
  • Suppose you have a string matching algorithm that can take in (linear)strings S and T and determine if S is a substring (contigu
    11·2 answers
  • PLEASE HELP
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!