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
V=pie r^2(h/3) what formula could be used to find the height of the cone
kodGreya [7K]

v =  \frac{1}{3} h{r}^{2} \pi

so

\frac{3v}{ {r}^{2} \pi}  = h

5 0
3 years ago
Find the x - and y -intercepts of the graph of the linear equation 3x+6y=24 .
True [87]

Answer:

x-intercept(s):

(8,0)

y-intercept(s):

(0,4)

5 0
2 years ago
Read 2 more answers
What is 278 minus 149
Basile [38]

Answer:

129

Step-by-step explanation:

278 - 149 = 129

5 0
3 years ago
Read 2 more answers
Solve for X.
Reika [66]

Answer:

By proportional method

\frac{4}{6}  =  \frac{5}{x}

4x= 30

x= 7.5

7 0
2 years ago
I need help on problem number 6 and 8 plzzzz
katrin [286]
For 6 I think it was B I am not so sure. Its been a long time since i did triangles
3 0
4 years ago
Read 2 more answers
Other questions:
  • Find the relation number between 3 and 4​
    9·1 answer
  • What is the area of this polygon
    10·1 answer
  • Alice has 150 sweaters on the shelves of her store each shelf holds 24 what is the minimum number of shelves she will need for d
    7·2 answers
  • PLEASE HELP ASAP 25 PTS + BRAINLIEST TO RIGHT/BEST ANSWER
    11·2 answers
  • Find the volume of the prism.<br> 3 ft<br> 7 ft<br> 5 ft
    14·1 answer
  • Using f(x) = 8x + 5 and g(x) = 7x - 2, find:f(g(4))
    7·2 answers
  • When something is refracted, it changes <br> direction<br> volume<br> size
    10·1 answer
  • Which of the following fractions is equivalent to a repeating decimal? A.1/3 , B.2/5, C.5/8
    8·1 answer
  • Can someone plz help me ?
    14·1 answer
  • Can someone help me with #1 #2 #3 please I really don’t understand
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!