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]
3 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]3 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
Cuáles son las partes más importantes de una flor​
castortr0y [4]

Answer:

estas son

Explanation:

El cáliz. Está formado por los sépalos, que son un conjunto de hojas verdes en la base de la flor.

La corola. Está formada por los pétalos que son hojas coloreadas en el interior de los sépalos.

Los estambres. Son los órganos masculinos de la flor. ...

El pistilo. Es el órgano femenino de la flor.

7 0
2 years ago
Windows administration allows a certain level of access for a file or folder to be assigned to a(n) ____________________ rather
soldi70 [24.7K]

Answer:

Group

Explanation:

A folder assigned to a single user can only be accessed by a single person, to get many users access a folder windows administrator shares a folder to a workgroup. using the simple steps below.

Login as the admin of the system, Right-click on the folder you want to give permission on, after clicking on properties, click on security, add user or group after clicking the edit. and your folder is shared to a group and all users in the group have access to it.

6 0
2 years ago
How to write a survey on cat theory​
nalin [4]
Start with a bold statement then follow with facts solutions problems and theory’s
3 0
2 years ago
Google is an example of a(n): Web site.search engine.search directory. subject directory
lora16 [44]
Google is famously known as a search engine and it is being used around the globe. Aside from being a search engine, it also offers other services such as productivity software or google docs, e-mail services like Gmail, cloud storage or the google drive and it also offers social networking services through google plus. Google also has some desktop application for free of use such as google chrome, picasa and instant messaging like hangouts. Their mission statement as for being the most used search engine is "to organize the world's information and make it universally accessible and useful".
6 0
3 years ago
A section at The top of the page that makes it easy for a recipient to respond to a letter is called an
Vesna [10]

its a  return address

8 0
2 years ago
Read 2 more answers
Other questions:
  • Binary search requires that the data to search be in order.<br> True or false
    13·1 answer
  • A ____ attack is much more substantial than a DoS attack because of the use of multiple systems to simultaneously attack a singl
    13·1 answer
  • Design a data structure to support the following two operations for a set S of inte- gers, which allows duplicate values: • INSE
    15·1 answer
  • You receive $50 as a birthday gift and choose to spend it all on new wallpaper for your room. The opportunity cost of this decis
    7·1 answer
  • What frequency band is used by bluetooth, 802.11b, and 802.11g?
    12·1 answer
  • Cuando hablamos de entornos digitales de enseñanza aprendizaje a que nos estamos refiriendo
    10·1 answer
  • Consider the recursive method whose definition appear below. Why? public static String mysteryString (String s){ if(s.length()==
    10·1 answer
  • I get such an error when I turn on the computer, how can I fix it?
    7·1 answer
  • Please help me with these questions​
    12·2 answers
  • Match the TCP/IP Layer to a problem that can happen there.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!