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
JulijaS [17]
2 years ago
15

Write a program which accepts two integers from the user. Then it asks the user what he wants to do with those two numbers. If t

he user choice is
‘A’ – Add the two numbers

‘B’ – Subtract the second number from the first number

‘C’ – Multiply the first number by the second number

‘D’ – Divide the first number by the second number

‘Q’ – End the operation

Your program should continue to accept the two numbers and the user choice unless the user enters ‘Q’ as choice.
Computers and Technology
1 answer:
il63 [147K]2 years ago
3 0

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to print choice menu

void menu()

{

   cout<<"A – Add the two numbers:"<<endl;

   cout<<"B – Subtract the second number from the first number:"<<endl;

   cout<<"C – Multiply the first number by the second number:"<<endl;

   cout<<"D – Divide the first number by the second number:"<<endl;

   cout<<"Q – End the operation:"<<endl;

}

// driver function

int main()

{

// variables

int x,y;

char ch;

int flag=1;

do{

   cout<<"Enter first number:";

   // read first number

   cin>>x;

   cout<<"Enter second number:";

   // read second number

   cin>>y;

   // call menu function

   menu();

   cout<<"Enter your choice:";

   // read choice

   cin>>ch;

   switch(ch)

   {

       case 'A':

       case 'a':

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

       break;

       case 'B':

       case 'b':

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

       break;

       case 'C':

       case 'c':

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

       break;

       case 'D':

       case 'd':

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

       break;

       case 'Q':

       case 'q':

       flag=0;

   }

   if(flag==0)

   break;

   

}while(ch!='Q'||ch!='q');

return 0;

}

Explanation:

Read two numbers from user.Then read the choice for operation on both the numbers. Then print the choices of operation by calling menu() function.If choice is "A"  then print Addition of both.if choice is "B" then print subtraction of second from  first number.if choice is "C" then print the multiplication of both numbers.If choice is "D" then print division of first by second.If the choice is "Q" then quit the operation. Repeat this until user's choice is "Q".

Output:

Enter first number:6                                                                                                      

Enter second number:2                                                                                                      

A – Add the two numbers:                                                                                                  

B – Subtract the second number from the first number:                                                                      

C – Multiply the first number by the second number:                                                                        

D – Divide the first number by the second number:                                                                          

Q – End the operation:                                                                                                    

Enter your choice:A                                                                                                        

Addition of two numbers is:8                                                                                              

Enter first number:8                                                                                                      

Enter second number:2                                                                                                      

A – Add the two numbers:                                                                                                  

B – Subtract the second number from the first number:                                                                      

C – Multiply the first number by the second number:                                                                        

D – Divide the first number by the second number:                                                                          

Q – End the operation:                                                                                                    

Enter your choice:Q      

You might be interested in
Which type of network involves buildings in multiple cities connecting to each other?
NeX [460]

Answer:

Power lines

Explanation:

Because their everywhere

4 0
3 years ago
The following pseudocode is an example of ____.do stepAdo stepBif conditionC is true thendo stepDelsedo stepEendifwhile conditio
rewona [7]

Answer:

Option d pretest

Explanation:

Given the pseudocode:

  1. do stepA
  2. do stepB
  3. if conditionC is true
  4. then do stepD
  5. else
  6. do stepE
  7. end if
  8. while conditionF is true
  9. do stepG
  10. end while

The pseudocode above shows that there is a pretest before some codes are executed. For example, line 3 check if condition is true then only execute stepD otherwise execute stepE. Line 8 check if conditionF is true then repeatedly execute stepG. These are examples of pretest a condition will must be met (pretest passed) before a block of codes can be executed. This pretest can be seen in if-else statements and also the while condition.  

6 0
2 years ago
Trudy is preparing a reply to an email message. Before she could send out the message, she is called for a meeting. If Trudy has
Ronch [10]
Her Drafts folder. Hope this helped!
3 0
3 years ago
Read 2 more answers
A(n) ________ collects data from various key business processes and stores the data in a single comprehensive data repository, u
xxTIMURxx [149]

Answer:

An Enterprise System

Explanation:

An enterprise system also refered to as an enterprise software is a computer software application used to handle the needs of a business or an enterprise examples are schools, production companies, government ministries and departments, charities etc.

The software provides all the business oriented services for the enterprise, services such as payment processing, students' information management, automated billing and payments etc.

Because enterprises will typically have different departments, the software is able to collect data from all the key business processes across all the departments into a single database which is useable according to different access privilages by all other parts of the enterprise.

3 0
2 years ago
Trucking A. is one of the least flexible transportation modes. B. is increasingly using computers to manage its operations. C. i
saw5 [17]

Answer:

B. is increasingly using computers to manage its operations.

Explanation:

Trucking -

It refers to the practice of using computer for the management purpose , is referred to as the process of trucking .

The method is very useful for the business and companies in order to adapt a faster and efficient mode of management .

Hence , from the given information of the question ,

The correct option is b. is increasingly using computers to manage its operations.

7 0
3 years ago
Other questions:
  • The first digital keyboard was the DX-7, introduced by the Yamaha company in 1983.
    15·1 answer
  • Assume that nextWord is a String variable that has been given a String value consisting entirely of letters. Write some Java cod
    6·1 answer
  • Can your computer become infected with a virus via email
    10·1 answer
  • PLZZZ HELP 30 POINTS!!
    14·1 answer
  • What is the sum of each pair of binary integers? (assuming 8-bit register is used)
    5·1 answer
  • Post as a reply your example of "data, which is processed into information" case - examples should not necessarily be related to
    13·1 answer
  • Write an HTML document which contains two text fields, a button, and a div. The first text field should be labeled “Temperature”
    10·1 answer
  • When you pass an argument to a method, the argument's data type must be ____________ with the receiving parameter's data type?
    11·1 answer
  • The _________________ can be used to repair common causes of unbootable operating systems. It is based on the Windows Preinstall
    6·1 answer
  • Given an array of integers a, your task is to calculate the digits that occur the most number of times in the array. Return the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!