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
Please!! I need help, this is due by tonight!!!
lyudmila [28]

Answer:

sorry if it is too late but I think it is d

Explanation:

4 0
3 years ago
Samuel loves playing the violin, but he feels embarrassed after a classmate posts a video on a social networking site making fun
Ksenya-84 [330]

Answer:

Number 1 would be the answer and most safest one to choose.

4 0
4 years ago
Read 2 more answers
May someone help please. :(
BigorU [14]

the 3rd one, if you ever watched a dvd (i know you have) if you read the copyright note you can be fined and you may end up in jail (for five or two years depending on what you did)

7 0
4 years ago
What is an example of constructive criticism for an employee who is shy during meetings?
rewona [7]
<span>Speak up more so people don't think you're rude</span>
8 0
4 years ago
Read 2 more answers
Is the expo class part of the java programming language answers?
alexandr1967 [171]
Yes, but usually only within HTML documents/pages.
6 0
4 years ago
Other questions:
  • What is the name of the malware included in CCleaner?
    11·1 answer
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • Developers and organizations all around the world leverage ______ extensively.
    9·2 answers
  • What do character formats do for your document's message? A. Set how text aligns within a document B. Provide organization C. Pr
    6·2 answers
  • Hi weegy, what is the latest android os?
    9·1 answer
  • Write a C++ program that takes two numbers from the command line and perform and arithmetic operations with them. Additionally y
    11·1 answer
  • 10<br> Which of the following is not one of the most popular Spreadsheet software applications?
    6·1 answer
  • Look at the slide. How could the slide best be improved? By reducing the number of visual aids by increasing the font size by da
    6·2 answers
  • In the world of computer languages, whats the most popular language?
    13·1 answer
  • Which would you use to get the number of elements in a dictionary?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!