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 list did poe appear on for the search engine lycos?
HACTEHA [7]
What list did Poe appear on for the search engine Lycos"
Millines most wanted number four. Edgar Allan Poe was born on January 19, 1809, in Boston, Massachusetts. His father, named David Poe Jr and his mother, named Elizabeth Arnold Hopkins Poe, were touring actors. 
4 0
3 years ago
Can someone pelaseee help
aalyn [17]

Answer:

Explanation:

develloppemetn de grace en option est logiquement une biologiste experimenter des annes 1256 a toulouse en france

6 0
2 years ago
Jordan has been asked to help his company find a way to allow all the workers to log on to computers securely but without using
lana66690 [7]

Answer:

Webcam

Explanation:

A webcam is mainly used for taking images or videos from the computer. the webcam is a combination of two basic words i.e. web and camera. webcam can be connected to any computer via USB. It can be mounted on the desktop and sometimes it comes inbuilt on the laptops.

A webcam is also used for face recognition function to login to a computer system.

so according to the scenario, the most appropriate answer is a webcam.

6 0
3 years ago
What does it mean when the lottery machine says function suppressed after scanning a ticket
WARRIOR [948]

When a machine  says function suppressed after scanning a ticket, it implies that you have won some certain amount.

<h3>What is lottery  wins?</h3>

This term connote that a person has  a winning ticket in a lottery that is often owned by a government.

Note that  if a winning ticket is scanned, the terminal often shows a message just for you and that suppress function implies  that your the ticket has won something.

Learn more about lottery  from

brainly.com/question/9216200

6 0
2 years ago
What is booting as used in computers?​
Sliva [168]

Answer:

the startup process

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
    11·2 answers
  • Anna always has a hard time finding files on her computer because she does not know where she saved them. This also affects her
    12·2 answers
  • 1. Problem solving is
    13·1 answer
  • A computer (mainframe, server, or workstation) that has an operating system enabling _____________ to access it at the same time
    11·1 answer
  • Why is Linux widespread in academic environments?
    7·1 answer
  • The local city youth league needs a database system to help track children that sign up to play soccer. Data needs to be kept on
    10·2 answers
  • (1)similarities between backspace key and delete key. (2) different between backspace key and delete key. (3) explain the term e
    10·1 answer
  • You would like to narrow your search on this topic.
    15·2 answers
  • which feature of organisations to manage needs to know about to build and use information system successfully
    6·1 answer
  • 4.8 code practice question 2
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!