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
Write the equation of the parabola that has the vertex at point (2,7) and passes through
Anton [14]

Answer:

f(x) =  \frac{4}{3} (x - 2) ^{2}  + 7

Step-by-step explanation:

the answer is :- .

f(x) =  \frac{4}{3} (x - 2) ^{2}  + 7

6 0
2 years ago
What digit makes each number divisible by nine?<br><br> _7,302
Alborosie

Answer:

Not completely sure but hopefully these will help.

Step-by-step explanation:

I'm kind of confused what you're asking for. If you could clarify that would be great. If you're trying to make it divisible by 9, you can either do 3, 6 or 9. If you want the first two digits: 2,5,8. Please clarify so I can help

8 0
4 years ago
Answer with proper units too!
EastWind [94]

Answer:

Step-by-step explanation:

1. Area of a parallelogram = base * height

 area = 10 * 4 = 40 in squared

perimeter = 2(a + b)

perimeter = 2 * (5 + 10) = 2 * 15 = 30in

2. Area of triangle = 1/2 * base * height

area = 1/2 * 21 * 8 = 84 cm squared

perimeter = sum of outer perimeters

perimeter= 10cm + 17cm + 21cm = 48cm

3.  area of trapezium = 1/2 * (a+b) * h

 area = 1/2 * (6+12) * 4 = 36ft squared

 perimeter = sum of outer perimeters

 perimeter = 5ft + 6ft + 12ft + 5ft = 28ft

3 0
3 years ago
Solve each system by substitution. -5x + 3y = 3 and -4x + y = 1
taurus [48]

\left\{\begin{array}{ccc}-5x+3y=3\\-4x+y=1&|\text{add 4x to both sides}\end{array}\right\\\\\left\{\begin{array}{ccc}-5x+3y=3\\y=4x+1&(*)\end{array}\right\\\\\text{Substitute }\ (*)\ \text{to the first equation}\\\\-5x+3(4x+1)=3\qquad\text{use distributive property}\\\\-5x+(3)(4x)+(3)(1)=3\\\\-5x+12x+3=3\qquad\text{subtract 3 from both sides}\\\\7x=0\qquad\text{divide both sides by (-5)}\\\\\boxed{x=0}\\\\\text{Substitute the value of x to}\ (*):\\\\y=4(0)+1\\y=0+1\\\boxed{y=1}\\\\Answer:\ x=0\ and\ y=1.

5 0
3 years ago
△PQR is dilated by a scale factor of with center , then translated 4units left and 3 units down. Construct the transformed trian
balu736 [363]

Step-by-step explanation:

45.78

4 0
3 years ago
Read 2 more answers
Other questions:
  • Suppose we roll a fair six-sided die and sum the values obtained on each roll, stopping once our sum exceeds 285. Approximate th
    5·1 answer
  • An experiment consists of choosing objects without regards to order. Determine the size of the sample space when you choose the
    12·1 answer
  • Annual salary plus bonus data for chief executive officers are presented in the BusinessWeek Annual Pay Survey. A preliminary sa
    11·1 answer
  • if an exterior angle of a regular polygon measures 15 degrees how many sides does it have ?a.23. b.24. c.25
    6·1 answer
  • Find slope of a line using points (2,0) and (4,3)
    6·1 answer
  • Solve each equation. Check your solution.<br><br> 2.2n + 0.8n + 5 = 4n
    8·1 answer
  • Hi can you please help me with this quickly, i don't want to fail
    9·2 answers
  • Terry Clayton has an open-ended lease for an SUV. The lease costs $421.38 for 48
    7·1 answer
  • What is the nth term rule of the linear sequence -5,-7,-9,-11,-13
    15·2 answers
  • Help i dont feel like doing the math
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!