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
A student comes to lecture at a time that is uniformly distributed between 5:09 and 5:14. Independently of the student, the prof
scZoUnD [109]

Answer:

1/2

Step-by-step explanation:

The lecture has already begun when the student arrives means one of these scenarios happen:  

1) the class started at 5:10 and the student arrives at 5:11 or 5:12 or 5:13 or 5:14

2) the class started at 5:11 and the student arrives at 5:12 or 5:13 or 5:14

3) the class started at 5:12 and the student arrives at 5:13 or 5:14

Given student time of arrival is uniformly distributed, then the probability he/she arrives at 5:09 or 5:10 or 5:11 or 5:12 or 5:13 or 5:14 is 1/6.

So,  the probability that the student arrives between 5:11 and 5:14 is 1/6 + 1/6 + 1/6 + 1/6 = 2/3.

The probability that the student arrives between 5:12 and 5:14 is 1/6 + 1/6 + 1/6 = 1/2.

The probability that the student arrives at 5:13 or 5:14  is 1/6 + 1/6 = 1/3.

Given class starting time is uniformly distributed, then the probability it starts at 5:10 or  5:11 or 5:12 is 1/3.

Given the two events are independent, the probability of the first scenario is: (1/3)*(2/3) = 2/9

For the second scenario:  (1/3)*(1/2) = 1/6

For the third scenario:  (1/3)*(1/3) = 1/9

Because all of these scenarios are mutually exclusive the total probability of one of them happen is: 2/9 + 1/6 + 1/9 = 1/2

3 0
2 years ago
Given the diagram below solve for x
kifflom [539]

Answer:

8.57

Step-by-step explanation:

y=AC

7/15=11/y

y=23.57

x=y-15

x=8.57

8 0
3 years ago
Part A: Suppose Jackson hiked due north on the first trail, and due east on the second trail. Show that the magnitude of the res
kotegsom [21]

Answer:

A) √((distance travelled due north)²+(distance travelled due east)²)

B) distance from starting point

C) Yes due west

Step-by-step explanation:

A) According to pythagoras theorem

resultant vector= √((distance travelled due north)²+(distance travelled due east)²)

Also see 1st attachment

B) The resultant vector tells the distance from the starting point

C) The same amount of distance travelled in opposite direction that is westwards will give same magnitude of resutlant vector.

See 2nd attachment

8 0
3 years ago
There are 5,280 feet in one mile. How many feet are there in 6 miles?
ella [17]
You simply multiply
5280*6= 31680

So your answer would be 31,680 ft in 6 miles

Hope this helps!<span />
7 0
3 years ago
Help plz:)))I’ll mark u Brainliest
Anvisha [2.4K]

Answer:

The answer to the question provided is 14.4 ft.

Step-by-step explanation:

We can solve this using proportion!

\frac{18}{x}  =  \frac{10}{8}  \\  \\  \frac{10x}{10}  =  \frac{144}{10}  \\  \\ x = 14.4

3 0
2 years ago
Other questions:
  • Evaluate the expression when a = 3.
    10·2 answers
  • In a survey, three out of seven people named blue as their favorite color. One out of six named red. If 1,092 people were includ
    7·2 answers
  • 2/9/10 + 1/10 <br> what is the answer
    12·1 answer
  • 1/2 divided by 4=______
    11·1 answer
  • Write a real life scenario that could be represented by this equation:
    6·1 answer
  • The cost of a car rental is ​$35 per day plus 19cents per mile. You are on a daily budget of ​$73. Write and solve an inequality
    10·1 answer
  • A grocery store sells 6 bottles of water for 4$ and 18 bottles of water for 10. Is the cost of the water proportional to the num
    12·1 answer
  • I need help on this question I need the answer please
    11·1 answer
  • Point b lies on ac between a and c. If Ab =8 and ac=10 find Bc
    12·1 answer
  • Find the median value. 1428, 961, 1258, 1324, 1185
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!