Write a program, using case statements, that mimics a calculator. The program should take as input two integers and the operation 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.

Answers

Answer 1

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:


Related Questions

What type of database replication relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy

Answers

Database replication is very common in this Era. Traditional database replication is relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy.

Database replication  is known to be the constant electronic copying of data from a database using one computer or server that is connected also to a database in another . this ensure that all users do share the same level of information.

Replication is often done to technologies which are used for copying and distributing data and database objects from one database to another and thereafter use in synchronizing between databases.

Conclusively, Replicas can only be made in the Traditional database replication through the power of centralized control.

See full question below

What type of database replication relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy?

a distributed database model

b. traditional database replication

c. enterprise replication

d. local database model

Learn more about database replication from

https://brainly.com/question/6447559

Consider the conditions and intentions behind the creation of the internet—that it was initially created as a tool for academics and federal problem-solvers. How might that explain some of the security vulnerabilities present in the “cloud” today?

Answers

It should be noted that the intention for the creation of the internet was simply for resources sharing.

The motivation behind the creation of the internet was for resources sharing. This was created as a tool for academics and federal problem-solvers.

It transpired as it wasn't for its original purpose anymore. Its users employed it for communication with each other. They sent files and softwares over the internet. This led to the security vulnerabilities that can be seen today.

Learn more about the internet on:

https://brainly.com/question/2780939

what are the main barriers to the adoption of an industry standard for internet system

Answers

Answer:

Industry experts say that although many companies find the potential of the Internet of Things very attractive, they either lack a clear value proposition for end-users or lack interoperability.

The capability of moving a completed programming solution easily from one type of computer to another is known as ________. Group of answer choices

Answers

Answer: Portability

Explanation: I hope it helps you!

Other Questions
What are villi?don't spam Solve for g.19 = 3g + 4g = The nurse is teaching a client about the potential for allergic drug reaction. What statement made by a client suggests a need for further teaching Lilly would like to start investing. What tools and services can she benefit from? A car salesman earns a 3% commission on sales. If he sells a car for AED 75,990, how much the commission amount will he earn if he sells 4 cars? things to make my mom listen to? $61.60 for parts and labor rate is $30.00 per hour total cost 136.60 how many hours will the job take? Write an equation and explain how you used it to find the number of hours the job will take. In what year did foreclosures reach their peak?A. 1920B. 1925C. 1927D. 1930 5. Identify the vertex of the parabola.A. (6, 3)B. (3, 0)C. (4, -1)D. (5, 0) Which of the following best describes the scientific exploration of the atom? When wearing a suit of armor, one would notice that it was generallyA.heavy and hot when worn.B.easy to put on by oneself.C.not worn in horse back.D.constructed of only a few pieces. Does anyone want to play prodigy with me? if so meet at Town Square in Lamplight Town in Sapphire World. I'm Serenity Nearshadow in that game. PLEASE! Help me please Im bad at slopes a leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate headquarters is located in Redmond Washington and it has offices in more then 60 countriesWhich One Is ItA) AppleB) MicrosoftC) IBMD) Global Impact how well did the landmases fit together this time 8x + 1/3 = 2/3 what is the answer? I need help with this please Using your outline and the materials youve gathered, write a 500- to 750-word paper using word processing software. Be sure to proofread and revise your writing to catch any errors in grammar, spelling, logic, or organization. Add a works cited page at the end to give credit to your sources. Submit your completed paper along with this activity to your teacher for evaluation.please do it based off of Werner Heisenberg the scientist. In a constant-pressure calorimeter, 55.0 mL of 0.340 M Ba(OH), was added to 55.0 mL of 0.680 M HCI. The reaction caused the temperature of the solution to rise from 22.21 C to 26.84 C. If the solution has the same density and specific heat as water (1.00 g/mL and 4.184J/g C.) respectively), what is A4 for this reaction (per mole H,O produced)? Assume that the total volume is the sum of the individual volumes. 6 + 2f = 8f = what the awnser i need help