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
The time between a lighting flash and the following thunderclap may be used to estimate, in kilometers, how far away a storm is.
Talja [164]
D=t/3

12=t/3
×3   ×3
___________
36=t

So the answer is D.) 36 kilometers
5 0
3 years ago
Which is a better buy 4 grapefruits for 80 cents or 12 grapefruits for $1.80?
PtichkaEL [24]
12 grapefruit for 1.80. so if you multiply. 80 cents by 3=2.40 for 12 but 1.80 us cheaper
8 0
3 years ago
Slope of 1,-7 and -3-4​
3241004551 [841]

\large \mathfrak{Solution : }

Slope of the given line is :

  • \dfrac{y_2 - y_1}{x_2 - x_1}

where ,

  • x_2 = 1

  • x_1 =  - 3

  • y_2 =  - 7

  • y_1 =   - 4

let's solve :

  • \dfrac{ - 7 - ( - 4)}{1 - ( - 3)}

  • \dfrac{ - 3}{4}

Slope = -3 / 4

4 0
2 years ago
Someone please give me the answers...And thank you
ale4655 [162]

Answer:

Step-by-step explanation:

1) 4x + 3 <= 3x - 5

Subtract 3 from both sides

4x + 3-3  <= 3x - 5 -3

4x  <= 3x - 8

Subtract 3x form both sides

4x - 3x <= 3x -3x - 8

x <= -8

6 0
3 years ago
Read 2 more answers
A gardener wants to create a rectangular vegetable garden in a backyard. She wants it to have a total area of 120 square feet, a
erastova [34]
Comment
This is an area problem. The key words are 120 square feet and 12 feet longer.
And of course width is a key word when you are reading this.

Formula
Area = L * W

Givens
W = W
L = W + 12

Substitute and Solve
Area = L* W
120 = W*(W + 12)
W^2 + 12W = 120 square feet
w^2 + 12w - 120 = 0

This does not factor easily. I would have thought that a graph might help but not if the dimension has to be to the nearest 1/100 of a foot. The only thing we can do is use the quadratic formula.

a = 1
b = 12
c = - 120

w = [ -b +/- sqrt(b^2 - 4ac) ]/(2a)
w = [-12 +/- sqrt(12^2 - 4*(1)(-120)] / 2*1
w = [-12 +/- sqrt(144 - (-480)]/2
w = [-12 +/- sqrt(624)] / 2
w = [- 12 +/- 24.979992] / 2 The minus root has no meaning whatever.
w = (12.979992) / 2
w = 6.489995 I'll round all this when I get done

L = w + 12
L = 6.489995 + 12
L = 18.489995

check
Area = L * W
Area = 6.489995*18.489995
Area = 119.999935 The difference is a rounding error

Answer
L = 18.489995 = 18.49 feet
W = 6.489995 = 6.49 feet

Note: in the check if you round first to the answer, LW = 120.0001 when you find the area for the check. Kind of strange how that nearest 1/100th makes a difference.
5 0
3 years ago
Other questions:
  • Sylvia placed 20 marbles in a bag: 10 red, 5 blue, green, 1 white. If
    5·1 answer
  • Billy starts counting backwards by 7, starting at 5907. when he reaches a single-digit number, he stops counting. what is the nu
    13·1 answer
  • What is 77/200 as a decimal/mixed number
    9·1 answer
  • What is the value of 8 exponent 3+5x when x=12
    13·1 answer
  • On average, Shawnte drinks 1/2
    10·1 answer
  • Find the y intercept of the line y+3=4(x+3)
    6·1 answer
  • <img src="https://tex.z-dn.net/?f=%5Csqrt%2096" id="TexFormula1" title="\sqrt 96" alt="\sqrt 96" align="absmiddle" class="latex-
    7·1 answer
  • Y=-5/2x-3 find the slope. plz I need it now
    6·2 answers
  • Evaluate the following integral or state that it diverges. <br><br> *integral 0 to 1 (ln x)do
    13·1 answer
  • There are 12 apples in a basket. Out of these, 3 apples are rotten. Find the probability of choosing a good apple.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!