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
CENGAGE MINDTAP Programming Exercise 4-8 Instructions Instructions Write a program that mimics a calculator. The program...
using Eclipse c++ Write a program that mimics a simple integer calculator using the switch statement. The program should prompt for two integer numbers and the operation to be performed as input. It should then output the numbers, the operator, and the results as illustrated below. Use a for loop to prompt the user for input seven times as illustrated below. Assume that the operands will always be valid integers. For division,the program should also output the remainder and check...
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 | 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 + 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 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 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 + >_ 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 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 ( + * / - ), 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
A Simple Calculator Summary: Write a console program (character based) to do simple calculations (addition, subtraction, multiplication and division) of two numbers, using your understanding of Java. Description: You need to write a program that will display a menu when it is run. The menu gives five choices of operation: addition, subtraction, multiplication, division, and a last choice to exit the program. It then prompts the user to make a choice of the calculation they want to do. Once the...