#include <iostream>
using namespace std;
float sum(float x, float y){
return x+y;
}
float subtract(float x, float y){
return x-y;
}
float multiply(float x, float y){
return x*y;
}
float divide(float x, float y){
return x/y;
}
int main() {
while(true){
cout << "Enter your choice: " << endl;
cout << "1. Sum" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cout << "0. quit" << endl;
int choice;
float x, y;
cin >> choice;
switch(choice){
case 1:
cout << "Enter 2 nubmers: " << endl;
cin >> x >> y;
cout << sum(x, y) << endl;
break;
case 2:
cout << "Enter 2 nubmers: " << endl;
cin >> x >> y;
cout << subtract(x, y) << endl;
break;
case 3:
cout << "Enter 2 nubmers: " << endl;
cin >> x >> y;
cout << multiply(x, y) << endl;
break;
case 4:
cout << "Enter 2 nubmers: " << endl;
cin >> x >> y;
cout << divide(x, y) << endl;
break;
case 0:
cout << "quit!" << endl;
return 0;
}
}
return 0;
}
***********************************************************************************************************
Please upvote the answer. It will encourage me to answer more questions and it will be very helpful to me. Thank You.
***********************************************************************************************************
Problem 9: (20 Points) Write a CH program to implement sum, subtraction, multiplication and division operations...
usingc++ 1. Write a program to find the Sum(), Subtraction(), Multiplication(), Division() operations using Switch statement. For Division operation, please include denominator equals to zero check.
Using c++.. 1. Write a program to find the sum(), Subtraction(), Multiplication(), Division() operations using Switch statement and functions. 2. Write a program to find the summation of N numbers. Use two functions. One function will take the input from user and the other will perform the summation from 1 to N. 3. Write a program to find the factorial of a number. Use two functions. One function will take the input from user and the other will perform the...
Problem 3 (35) Design a calculator that performs four operations: addition, multiplication, division and subtraction with 2 integer type numbers a) Ask user what type of operation to perform (+, , * or/) a. If the user inputs 'none' then the program terminates. Otherwise it will keep continuing the calculation. (hint: use while) b) Ask user to provide 2 integer number inputs c) Perform operation (whatever operation they mentioned in a) d) Print result e) In division operation, perform a...
The matrix operations that you should include are Addition, Subtraction and Multiplication. The driver can be as simple as asking the user to enter two matrices and then presenting a simple menu that allows the user to select the operation they want to test. Have the menu in a loop so that the user can test any other operation unless they choose to exit the menu. Also, provide the user an option to select two new matrices. Make sure that...
Write a Python Program that displays repeatedly a menu as shown in the sample run below. The user will enter 1, 2, 3, 4 or 5 for choosing addition, substation, multiplication, division or exit respectively. Then the user will be asked to enter the two numbers and the result for the operation selected will be displayed. After an operation is finished and output is displayed the menu is redisplayed, you may choose another operation or enter 5 to exit the...
Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for list of operations that can be calculated and get the input from user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations must be...
Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for the list of operations that can be calculated and get the input from the user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations...
Write a C program to implement matrix multiplication operations. First, you need to prompt the user for the size of both matrix. Then take inputs for both matrices and perform matrix multiplication operation. Finally, print the resulting matrix into the output.
PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors). : Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support...
In VS if you can please!! Multiplication write a program that executes the multiplication of two numbers entered by the user using only the addition operation. For example, if the user enters 3 and 4, the program computes the multiplication of these numbers by adding the number 4 three times (i.e., 3 * 4 = 4 + 4 + 4). Solve this problem in the most efficient way.