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
Fynjy0 [20]
3 years ago
9

Write a program, using case statements, that mimics a calculator. The program should take as input two integers and the operatio

n to be performed. It should then output the numbers, the operator, and the result. For division, of the denominator is zero, output an appropriate message.
Computers and Technology
1 answer:
marissa [1.9K]3 years ago
6 0

Answer:#include<iostream>

using namespace std;

int main() {

int var1, var2;

char operation;

cout << "Enter the first number : ";

cin >> var1;

cout << endl;

cout <<"Enter the operation to be perfomed : ";

cin >> operation;

cout << endl;

cout << "Enter the second nuber : ";

cin >> var2;

cout << endl;

bool right_input = false;

if (operation == '+') {

cout << var1 << " " << operation << " " << var2 << " = " << (var1 + var2);

right_input = true;

}

if (operation == '-') {

cout << var1 << " " << operation << " " << var2 << " = " << (var1 - var2);

right_input = true;

}

if (operation == '*') {

cout << var1 << " " << operation << " " << var2 << " = " << (var1 * var2);

right_input = true;

}

if (operation == '/' && var2 != 0) {

cout << var1 << " " << operation << " " << var2 << " = " << (var1 - var2);

right_input = true;

}

if (operation == '/' && var2 == 0) {

cout << "Error. Division by zero.";

right_input = true;

}

if (!right_input) {

cout << var1 << " " << operation << " " << var2 << " = " << "Error;";

cout << "Invalid Operation!";

}

cout << endl;

system("pause");

return 0;

}

Explanation:

You might be interested in
The ability of services to grow or shrink based on need is called __________.
Talja [164]
This kind of ability is called rapid elasticity. The resources can be maximized by a consumer to provide wider webs and applications.It can also make the server stop, just to reduce the cost in the process.  The flexibility in adapting to needs of a company is an advantage. Rapid elasticity can be done in a public cloud.
3 0
4 years ago
In Python which is the correct method to load a module math?
Wittaler [7]

Answer: The math module is a standard module in Python and is always available. To use mathematical functions under this module, you have to import the module using import math .

Explanation:

3 0
3 years ago
DO MOBILE DEVICES HAVE TO WORK IN LIMITED SCREEN SPACE
Taya2010 [7]
Yes, mobile devices have to work in limited screen space.
8 0
3 years ago
Read 2 more answers
The programming language that translates digital data into printer commands is known as
jolli1 [7]
The answer is C.) PostScript
8 0
3 years ago
What is the maximum number of characters you can have in a file name​
Leokris [45]

Answer:

255 number of characters including space, \ etc.

5 0
3 years ago
Other questions:
  • Suppose you with had two algorithms, A and B, with growth functions fa(n)=200n2 and fb(n)=2n4. If you were to do an exact analys
    13·1 answer
  • IF ACCURATE = BRAINLY (if u answer rubbish randomness= reported AND if you got questions dont ask in answer slot= reported)
    13·1 answer
  • PLEASE HELP!!!!
    7·1 answer
  • Project manager Erica is discussing with her team to prepare a document to describe the deliverables and goals of a software pro
    13·1 answer
  • Please help if you answer correcly i will give you brainelst!!!!!!!!!!!!!!!!!!
    6·2 answers
  • Why would a programmer use a flow chart? (Edge2020 Coding Critical Thinking Questions)
    9·1 answer
  • Help!!
    15·1 answer
  • Pls help! for computers edge 2021
    7·1 answer
  • What is the main circuit board inside the computer called?CD-ROMY
    12·1 answer
  • Write a loop that continually asks the user what pets the user has until the user enters stop, in which case the loop ends. It s
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!