Write a program to simulate a basic calculator. [+,/%]. Use switch statement.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

QUESTION PROVIDED IN ATTACHMENT.

ONLY USE SHELL SCRIPTING WHEN MAKING SOLUTION

Write a program to simulate a basic calculator. [+,/,%]. Use switch statement.
2 3
Input Format:
The first line of the input consists of an integer which corresponds to a.
The second line of the input consists of a character that corresponds to the operator.
The third line of the input consists of an integer which corresponds to b.
Output format:
The output consists of a single line. Refer to sample output for details.
Sample Input 1:
3
Sample Output 1:
The sum is 8
Sample Input 2:
7
6
Sample Output 2:
The difference is 1
Sample Input 3:
4
Sample Output 3:
The product is 12
Sample Input 4:
12
Sample Output 4:
The quotient is 4
Sample Input 5:
4
%
2
Sample Output 5:
The remainder is O
Sample Input 6:
2
Sample Output 6:
Invalid Input
Transcribed Image Text:Write a program to simulate a basic calculator. [+,/,%]. Use switch statement. 2 3 Input Format: The first line of the input consists of an integer which corresponds to a. The second line of the input consists of a character that corresponds to the operator. The third line of the input consists of an integer which corresponds to b. Output format: The output consists of a single line. Refer to sample output for details. Sample Input 1: 3 Sample Output 1: The sum is 8 Sample Input 2: 7 6 Sample Output 2: The difference is 1 Sample Input 3: 4 Sample Output 3: The product is 12 Sample Input 4: 12 Sample Output 4: The quotient is 4 Sample Input 5: 4 % 2 Sample Output 5: The remainder is O Sample Input 6: 2 Sample Output 6: Invalid Input
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning