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
Maria's manager asked her to print a certain document for their meeting. It took her so long to find the file that she was late
Hoochie [10]

hey let me and sans help. . . . .hmmm. . .

sans said create a word-processing document that lists where she has saved files.

9 0
3 years ago
Read 2 more answers
What term is the ability to restore service quickly and without lost data if a disaster makes your components unavailable or it
oksian1 [2.3K]

Answer:

"Recoverability" is the appropriate solution.

Explanation:

  • The above refers to either the DBMS work timetables where only certain processes are conducted out only when all transactions where such modifications are learned by the submission are implemented or operated.
  • This technique is used to reinstate make informed even without system failures.
8 0
3 years ago
A website whose URL ends with .gov, .edu, or .org is necessarily a reliable source. True or False
natali 33 [55]
True because they are educational anything .com and sometimes .net because .gov is from the government so it is very safe to use and .edu is for education it is always used to help people with education etc and .org is   public which other people can say false and save you from false information
7 0
2 years ago
When processing all the elements of row i of a two-dimensional array named grades using a for loop with variable j, what is the
kykrilka [37]

Answer:

D

Explanation:

Two dimensional array contain both rows and columns. Each row represented one record and each column represent one filed in that record.

for ex: int grades[5][3];

here array grades contains 5 rows and in each row we have 3 columns

if we have grades[i][j] then " i " represents number of rows and j represents the number of columns in that row.

j<grades[i].length represents i=0 to 2[here no of columns are 3, array index starts from 0 to 2]

The Answer is D

8 0
3 years ago
The undo button allows you to reverse up to ____ previous actions, one at a time.
Maurinko [17]
The undo button allows you to reverse up to 100 previous actions, one at a time.<span> The undo button is found in the toolbar. It erases the last change done to the document reverting it to an older state.</span><span> The change can be formatting text, moving blocks, typing and deleting text.

</span>
6 0
3 years ago
Other questions:
  • SP 800-14, Generally Accepted Principles and Practices for Securing Information Technology Systems, provides best practices and
    9·2 answers
  • Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
    15·2 answers
  • Which of the following is a useful policy to minimize waste and mistakes?
    6·1 answer
  • Examples of algorithm
    5·1 answer
  • What does "FDDI" stand for in Technology?
    5·2 answers
  • What is Processor to Memory Mismatch problem?
    15·1 answer
  • 4. Together, what do the divisions of the DHSMV do? A. Make sure lines are long B. Use more money than other government organiza
    14·1 answer
  • Need help ASAP Examples of utilities that make it possible for people to create and share multimedia files include _____. audio
    9·2 answers
  • Complete the statement about WYSIWYG editors when you use a WYSIWYG editor you typically specify the continent and blank A.layou
    5·1 answer
  • Critical Thinking Questions
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!