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
Given two variables firstInClass and secondInClass which have already been associated with values, write code which swaps the va
valentina_108 [34]

Answer:

Following are the code in the python language

if firstInClass.startswith("Pat") and secondInClass.startswith("Wei"):  #check the #condition

   firstInClass, secondInClass = secondInClass, firstInClass #swap value

Explanation:

Following are the description of statement

  • Firstly we check the condition the string start with pat with the string start with the Wei string along with the and operator with them .
  • If the condition is true then it executed the block of if statement means executed the statement inside the if block .It means it swap the statement without assigning the value .
8 0
4 years ago
Why is it important to use a structured cabling standard when installing and managing cabling systems?
Bumek [7]

Answer:

Because it is a industry standard and it describes the best way to install networking media to maximize performance and minimize upkeep.

Explanation:

Structured cabling consists of best-practices involving the design and construction of your telecommunication infrastructure. These practices help standardize your telecom cabling structure to facilitate interoperability, moves and additions, and system dependability.Even though cables and wires are generally hidden behind walls, structured cabling solutions provide much needed benefits to businesses and data centers. Without it, the system is put at risk, especially during maintenance.

8 0
3 years ago
In both direct flooding attacks and _____ the use of spoofed source addresses results in response packets being scattered across
Natali5045456 [20]

Answer:

SYN spoofing attacks.    

Explanation:

The Spoofing attack is used to access the personal information it is distributed the  viruses through infected links or file .The spoofing attacks has redistributed the traffic and the flow control in the denial-of-service attacks.

The SYN spoofing attacks is used the spoofed source in the result of giving response to packet The Spoofing attack  is distributed  across the Internet also it is detectable

6 0
3 years ago
Hard drives have the largest capacity of any storage device. <br> a. True <br> b. False
VMariaS [17]
It's false as they store way lesser than we think
3 0
3 years ago
Read 2 more answers
True or false FAFSA awards work study, but jobspeaker can be used to learn which jobs are available
Kruka [31]

Answer:

true

Explanation:

random because it's FAFSA and that ain't a word

3 0
2 years ago
Other questions:
  • Based on the chart below, which pie flavors make up approximately one-half of the total? A pie chart shows the following pie fla
    7·2 answers
  • Which of the following represents the bus topology? Multiple Choice All devices are connected to a central device, called a hub.
    8·1 answer
  • Consider the following scenario below and recommend a solution.
    8·1 answer
  • Design and implement a program (name it Youth) that reads from the user an integer values repressing age (say, age). The program
    6·1 answer
  • Which of the following best describes the displayport interface used for connecting video monitors to computers
    11·1 answer
  • Tests that replace_punctuation() replaces 1 exclamation point and 2 semicolons in "we'll continue our quest in space. there will
    14·1 answer
  • Convert 3BA.25 (base 14) to base 6 ? Show all arithmetic in decimal
    5·1 answer
  • What finger should be on the K key?<br> 1. Pinky<br> 2. Index <br> 3. Middle <br> 4. Ring
    9·1 answer
  • Jim lost his job due to the replacement of robots in a manufacturing factory. As an ethical practice, what should the manufactur
    13·1 answer
  • At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!