Question

CENGAGE MINDTAP Programming Exercise 4-8 Instructions Instructions Write a program that mimics a calculator. The program shou
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Providing code in C++

#include <iostream>
using namespace std;

int main()
{
int a,b;
double result;
char operation;
cout<<"Enter the first integer: ";
cin>>a;
cout<<"Enter the second integer: ";
cin>>b;
cout<<"Enter the operation to be performed: ";
cin>>operation;
switch(operation)
{
case '+':
result=a+b;
cout<<a<<endl;
cout<<b<<endl;
cout<<operation<<endl;
cout<<result<<endl;
break;
case '-':
result=a-b;
cout<<a<<endl;
cout<<b<<endl;
cout<<operation<<endl;
cout<<result<<endl;
break;
case '*':
result=a*b;
cout<<a<<endl;
cout<<b<<endl;
cout<<operation<<endl;
cout<<result<<endl;   
break;
case '/':
if(b==0)
{
cout<<"error denominator cannot be 0"<<endl;
break;
}
result=(double)a/b;
cout<<a<<endl;
cout<<b<<endl;
cout<<operation<<endl;
cout<<result<<endl;   
break;
}

return 0;
}
OUTPUT:

Enter the first integer: 6
Enter the second integer: 5
Enter the operation to be performed: /
6
5
/
1.2


Add a comment
Know the answer?
Add Answer to:
CENGAGE MINDTAP Programming Exercise 4-8 Instructions Instructions Write a program that mimics a calculator. The program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Creating a Calculator Program

    Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...

  • byst x Grades for Lewis Dickerson: (Sun X MindTap - Cengage Learning х Python Programming |...

    byst x Grades for Lewis Dickerson: (Sun X MindTap - Cengage Learning х Python Programming | Facebook x war Python: Inp Cengage.com/static/nb/ui/evo/index.html?deploymentid=58296224090012788153144858955&eISBN=9781337560115&id=811000539&snap CENGAGE MINDTAP Programming Exercise 1.7 Instructions myinfo.py ols V- 1 name= input 2 age = int(in 3 print("Alex Write and test a program that accepts the user's name (as text) and age (as a number) as input. . 4 The program should output a sentence containing the user's name and age. S An example of the program input...

  • . CENGAGE MINDTAP Q Search this course OX Programming Exercise 2-3 0 Instructions InchesToCentimeters... Σ. Terminal...

    . CENGAGE MINDTAP Q Search this course OX Programming Exercise 2-3 0 Instructions InchesToCentimeters... Σ. Terminal + 3 inches is 7.62 centimet ers Convert the InchesToCentimeters program to an interactive application named InchesToCentimetersInteractive. 600 vau AWN 1 using static System.Console; 2 class InchesToCentimeters Interactive 3 { static void Main() 5 { 6 const double CENTIMETERS_PER_INCH = 2.54; double inches = 3; Line("{0} inches is {1} centimeters", inches, inches * CENTIMETERS_PER_INCH); Instead of assigning a value to the inches variable, accept...

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    Write an assembler program that asks the user (as shown below) for two integers and a single character representing the arithmetic operations: addition, subtraction, multiplication and integer division (displays both quotient and remainder). Perform the requested operation on the operands and display the result as specified below. Assume SIGNED NUMBERS. The program should not divide by 0! If the user attempts to divide by 0, display the error message: "Cannot divide by zero." If this error occurs, the program should...

  • I have a question on an assignment for C++. I have my code available here and...

    I have a question on an assignment for C++. I have my code available here and just want someone to look over it using MS VS 2010 express, for that is what my instructor is using. Write a program that mimics a calculator. The program should take as input two integers and the opreation to be performed. It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message.) //**This...

  • Python pls CENGAGE MINDTAP Q Search this course Programming Exercise 11.1 x Instructions search.py + >_...

    Python pls CENGAGE MINDTAP Q Search this course Programming Exercise 11.1 x Instructions search.py + >_ Terminal + A sequential search of a sorted list can halt when the target is less than a given element in the list. 1 " 2 File: search.py 3 Project 11.1 4 5 Optimizes sequential search for sorted lists. 6 The complexity is O(n) in the worst case and 0(1) in the best case. 7 The average case is less than n / 2,...

  • not getting correct values CENGAGE I MINDTAP Programming Exercise 4-6 | Instructions Circle 5 Create a...

    not getting correct values CENGAGE I MINDTAP Programming Exercise 4-6 | Instructions Circle 5 Create a class named circle with fields named radius , dianeter and area . Include a constructor 6 td ch that sets the radtus to 1 and sp 9 16 calculates the other two values. Also include methods named setRadtus and getRadius() The setRadius() method not only sets the radtus , but it also calculates the other two values. (The diameter of a circle is twice...

  • Q2- Write a C program that work as a calculator for the 4 main operations (...

    Q2- Write a C program that work as a calculator for the 4 main operations ( + * / - ), an error message should be displayed when the user attempts to divide by zero. The user input should be in this form: Number operation number, ex: 2-3‏

  • Program Instructions: Write a C++ program that uses a random number generator to generate a two...

    Program Instructions: Write a C++ program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: Double the number. Reverse the digits of the number. Raise the number to the power of 2, 3, or 4. Sum the digits of the number. If the number is a two digit number, then raise the first digit to the power of the second digit. If the...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT