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]
3 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]3 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
What is the full form of EPROM (CLASS-6)
vodomira [7]

Answer:

earth planet rest orbit moon

4 0
2 years ago
Read 2 more answers
100+20000000 please give answer and win iPhone 11 pro​
Eddi Din [679]

Answer:

20000100

Explanation:

8 0
2 years ago
The celestial sphere is divided into
7nadin3 [17]

Answer:

A.

Explanation:

4 0
3 years ago
Read 2 more answers
What utility is used to verify that tcp/ip installed, bound to the nic, configured correctly, and communicating with the network
klasskru [66]
<span>PING is a utility that can verify that TCP/IP is installed, bound to the NIC, configured correctly, and communicating with the network. Ping is used diagnostically to ensure that a host computer the user is trying to reach is actually operating. Ping works by sending an Internet Control Message Protocol (ICMP) Echo Request to a specified interface on the network and waiting for a reply. Ping can be used for troubleshooting to test connectivity and determine response time.</span>
6 0
3 years ago
Your organization employs a group of traveling salespeople who need to access the corporate home network through the internet wh
Over [174]

Answer:

<em>VPN concentrator</em>

Explanation:

A VPN concentrator (Virtual Private Network Concentrator) <em>is a sort of communication system that ensures stable VPN connections are established and  messages are transmitted across VPN nodes. </em>

It is a form of networking device designed primarily for VPN  communication network development and management.

It mainly enhances a VPN router's features by  incorporating specialized communications data and network security.

8 0
3 years ago
Other questions:
  • 20 Points!! Please hurry!!
    9·1 answer
  • Jenny is working on a laptop computer and has notices that the computer is not running very fast. She looks and realizes that th
    6·2 answers
  • This matches the domain name with the correct IP address:
    12·1 answer
  • Analyze the following code: class Test { public static void main(String[] args) { System.out.println(xMethod((double)5)); } publ
    7·1 answer
  • Indica si los elementos de las imagenes son una materia prima o un material elaborado
    12·1 answer
  • Write a static method called split that takes an ArrayList of integer values as a parameter and that replaces each value in the
    12·1 answer
  • jeff has just upgraded from windows 7 to windows 10 and he is confused. He has started several universal apps but he can't figur
    11·1 answer
  • 10. List three adaptations of wind-pollinated plants to promote pollination.<br>​
    12·1 answer
  • Because Brainly is such a big organization for students in need of help with their school work, I believe that it was either som
    15·1 answer
  • The field that uses technology to manipulate and use information to improve healthcare is known as:_______
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!