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
Allisa [31]
3 years ago
8

Write a program that mimics a calculator. The program should take as input: The first integer The second integer The operation t

o be performed (+, -, *, /)
Mathematics
1 answer:
SashulF [63]3 years ago
7 0

It takes value from a user and then user the operation of (+,-,*/).

i used c++ programming language to solve this program:

#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;

}

You might be interested in
Use special right triangle ratios to find the length of the hypotenuse.
Nady [450]

Answer:

Step-by-step explanation:

8 0
3 years ago
What is negative 1/4 to the 3rd power
Y_Kistochka [10]

Answer:

-1/64

Step-by-step explanation:

Just do 4 to the 3rd and make that the denominator

4^3 = 64

-1 / 64

7 0
3 years ago
Read 2 more answers
Decimals greater than 7.0 but less than 13.0 use an interval of 0.6 between each pair of decimals
KiRa [710]
7.6, 8.2, 8.8, 9.4, 10.0, 10.6, 11.2, 11.8, 12.4
7 0
3 years ago
What is the least common denominator for the fractions 16and34?
fenix001 [56]

Answer:

4

Step-by-step explanation:

6 0
2 years ago
How long does it take to drive 300 miles at 60 mph?
olga55 [171]
It would take 5 hours
4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the sales tax for a purchase of $2,500
    10·2 answers
  • Which inequality is true?
    11·1 answer
  • What is the cosine of 30?
    5·2 answers
  • A vessel sails 41 miles S 35° E. How far south has it sailed?
    14·1 answer
  • Lin can read at rate of 20 pages in 35 minutes she just borrowed a book from library that 48 pages how many minutes will it take
    13·1 answer
  • In right triangle ABC, altitude CD is drawn to its hypotenuse. Select all triangles which must be similar to triangle ABC.
    12·2 answers
  • A parallelogram is shown below. Which equation best represents the formula for the area of the parallelogram?
    9·1 answer
  • Mrs pender shows her students 2 sticks measuring 6 inches and 2 sticks measuring 8 inches. She asked the student to arrange the
    11·1 answer
  • Suppose you deposit $2,500 in a savings account that pays interest at an annual rate of 6%. If no money is added or withdrawn fr
    9·1 answer
  • Does anyone know the answer to this ?? PLEASE HELP.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!