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]
2 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]2 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
3(x - 6) + 6 = 5x - 6. what is the solution<br>​
4vir4ik [10]

Answer:

x=-3

Step-by-step explanation:

Step 1: Simplify both sides of the equation.

3(x−6)+6=5x−6

(3)(x)+(3)(−6)+6=5x+−6(Distribute)

3x+−18+6=5x+−6

(3x)+(−18+6)=5x−6(Combine Like Terms)

3x+−12=5x−6

3x−12=5x−6

Step 2: Subtract 5x from both sides.

3x−12−5x=5x−6−5x

−2x−12=−6

Step 3: Add 12 to both sides.

−2x−12+12=−6+12

−2x=6

Step 4: Divide both sides by -2.

−2x

−2

=

6

−2

x=−3

7 0
3 years ago
Read 2 more answers
Write <br> 2/9 as a repeating decimal.
grigory [225]

Answer:

.2 repeating

Step-by-step explanation:

if you are allowed to use calculators, then do so, if not, you're going to have to do a lot of division

8 0
3 years ago
Read 2 more answers
Connie keeps her sports card collection in a 54-page book. Each page has 9 slots for cards.
vesna_86 [32]

Answer:

324 slots.

Step-by-step explanation:

If there is 9 slots per page, and 18 pages in the 54 page book are taken up by football cards, that leaves you with 36 pages left. Again, 9 slots per page, so you multiply 9 x 36 and get 324 slots available for baseball cards.

7 0
2 years ago
Read 2 more answers
What is the answer to -6(4r+2)+5
RideAnS [48]

Answer:

-24r - 7

Step-by-step explanation:

-6(4r + 2) + 5

-24r - 12 + 5

-24r - 7

Best of Luck!

5 0
3 years ago
Please help thank you
marissa [1.9K]
The absolute value of y is further from 0.

Explanation:
The absolute value of any number is a positive. If the value of y is greater than x, then y would be further. Let’s input a number as an example. Let’s say that the absolute value of y was 9 and the absolute value of x is 4 due to the y value being larger. 4 is closer to 0 compared to 9 so the absolute value of y is further from 0.
3 0
2 years ago
Other questions:
  • Isabella buys a 1.75 litre carton of apple juice. What is the largest number of 200 millilitre glasses that she can have from th
    15·1 answer
  • What is the answer to the math problem 5+9(2+4)?
    13·2 answers
  • Help please i really need it asap
    5·1 answer
  • What is the rock style
    5·1 answer
  • What is the probability that a person who is older than 35 years has a hemoglobin level between 9 and 11? A. 0.257 B. 0.284 C. 0
    9·1 answer
  • 2-2x&gt;-20<br> A. x&gt; 12<br> B. x &lt;9<br> C. x &lt; 10<br> D. x &lt; 11
    11·2 answers
  • Based on the graph below, what is the total number of solutions to the equation f(x) = g(x)? (1
    9·1 answer
  • 2. In your own words, explain HOW to find the standard deviation of this data set. (20 points) 3. What does the standard deviati
    8·1 answer
  • Enter an angle that is vertical with /_AXB in the diagram below:
    8·2 answers
  • Round each number to the<br> nearest 10 and 100.<br> 444 <br> 372<br> 847<br><br> Help please
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!