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
Choose the number from each drop-down menu that best completes the sentence,
siniylev [52]

Answer:

Maya mistake is in step 1

Step-by-step explanation:

6 0
3 years ago
Read 2 more answers
You owe $1568 on a credit card with a limit of $2200 at an interest rate of 11.3% APR you pay $300 a month until it is paid off
miv72 [106K]
Given the information above, with $300.00 monthly payment, owed amount plus interest on a credit card will be paid off after five and a half months. Total interest paid will be amounting to $81.21.
7 0
3 years ago
What is the exact volume of the cylinder?
goldenfox [79]
1. Find the radius of the circular base.
<span>2. Calculate the area of the circular base. </span>
<span>3. Find the height of the cylinder. </span>
<span>4. Multiply the area of the base by the height.</span><span>5. State your final answer in cubic units</span>
6 0
4 years ago
Given the first term and common difference, find the first four terms and the formula
mylen [45]
Your awnser is 777777777777.66
4 0
3 years ago
Whats 1/7 divided by 2/5
Marianna [84]

Answer:

Step-by-step explanation:

(1/7) / (2/5)

when dividing fractions, flip what u r dividing by, then multiply

1/7 * 5/2 = 5/14 <==

8 0
3 years ago
Other questions:
  • Three students were asked to find the cube root of 216. Each student’s method is shown below.
    5·2 answers
  • Is (1,2) a solution of 6x-y&gt;3
    5·1 answer
  • (4+5)÷3×4= <br>can someone help me with this question please
    6·1 answer
  • The area of a square field is 841m.A rectangular field whose length is twice it's breath has its perimeter equal to square field
    7·1 answer
  • Which expression is equivalent to 15n – 20?
    12·2 answers
  • Erika's lunch cost $13.00. She wants to leave a 15% tip. What is the tip amount?
    11·2 answers
  • Which two ratios form a proportion?
    8·1 answer
  • Transformation of parent Functions I need help
    8·1 answer
  • What is slope (mathmatical slope) explain
    9·2 answers
  • I need help!! I will give 5.0 star ​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!