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
An artist can paint
kolezko [41]

Answer:

23,760/12=1980

1980x2=3960

7 0
3 years ago
PLEASE HELP ME!!!
Harman [31]
Send a better photo or tell me what I’m suppose to be answering
8 0
3 years ago
Select Statistical or Not statistical to classify each question.
Oxana [17]

Answer:

the first in is not statistical because it id not a relevant question

the second is statistical because it is asking a relevant question that requires a factual answer while the first one does not have any factual information involved in the answer

Step-by-step explanation:

Hope this helps have a wonderful day

-GayBoi456

5 0
3 years ago
Read 2 more answers
Jayden is running laps at track practice. The track is 25 kilometers around. Jayden runs 1 lap in 2 minutes. How many minutes do
givi [52]

Answer:

0.08 minutes for a kilometer.

Step-by-step explanation:

If the track is 25 kilometers, and he runs 25 kilometers in 2 minutes, he runs a kilometer in 2÷25 minutes or 0.08 minutes which is 4.8 seconds.

I'm pretty sure the track isn't 25 kilometer or he can't run a lap in 2 minutes. But if so, the answer is 0.08 minutes.

8 0
3 years ago
A college student needs 11 classes that are worth a total of 40 credits in order to complete her degree. The college offers both
ipn [44]
7 4-credit classes. 4 3-credit classes.

7*4 = 28, and 4*3 = 12. 11 classes, and 40 credits.
3 0
3 years ago
Other questions:
  • If y=4x + 3 find the value of y when x= -2
    7·2 answers
  • Alisa hopes to play beach volleyball in the olympics someday. She has convinced her parents to allow her to set up a beach volle
    9·1 answer
  • Which equation represents the volume of a cone with the same base and height as the cylinder below?
    15·1 answer
  • Five fewer than x is at most eighteen. What is the solution set for x?
    10·2 answers
  • You are choosing a passcode for your new phone. It has to be a 6 digit code using the numbers 0-9. You are allowed to repeat a n
    12·1 answer
  • The cost to rent a dump truck is $50 per day plus $26 per hour of use. What is the maximum number of hours the truck can be used
    8·1 answer
  • The time it takes to fly from Los Angeles to New York varies inversely as the speed of the plane. If
    13·1 answer
  • Helpppp 2x-1&gt;5 and 3x-5&lt;19
    12·1 answer
  • Find the LCM of: 14a^4n^2 and 35a^3mn^2 https://brainly.com/question/25332219
    13·1 answer
  • A company mixes pecans, cashews, peanuts, and walnuts to make a batch of mixed nuts.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!