Program:
# Menu display
print("===== MAIN MENU =====")
print("1. Addition")
print("2. Subtraction")
print("3. Exit")
print("\n")
# Read input for menu option from user
menu = int(input("Select an operation (1-3): "))
# Loop iterates till the menu is not equal to 3
while menu != 3:
# Reading two number input from user
num1, num2 = map(int, input("Enter two numbers: ").split())
# Condition to check for addition option
if menu == 1:
# Printing the addition of given two numbers
print(num1,"+",num2,"=",num1+num2)
# Condition to check for subtraction option
elif menu ==2:
# Printing the subtraction of given two numbers
print(num1,"-",num2,"=",num1-num2)
print("\n")
# Printing menu
print("===== MAIN MENU =====")
print("1. Addition")
print("2. Subtraction")
print("3. Exit")
print("\n")
# Read menu selection from user
menu = int(input("Select an operation (1-3): "))
# If user wants to exit
if menu == 3:
# Print Bye as output
print("Bye!!!")
Output:
in python and use while loop Exercise: Complete the program that performs basic arithmetic operations of...
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...
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...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
// Arithmetic2.java - This program performs arithmetic, ( +. -, *. /, % ) on two numbers // Input: Interactive. // Output: Result of arithmetic operation import javax.swing.*; public class Arithmetic2 { public static void main(String args[]) { double numberOne, numberTwo; String numberOneString, numberTwoString; String operation; double result; numberOneString = JOptionPane.showInputDialog("Enter the first number: "); numberOne = Double.parseDouble(numberOneString); numberTwoString = JOptionPane.showInputDialog("Enter the second number: "); numberTwo = Double.parseDouble(numberTwoString); operation = JOptionPane.showInputDialog("Enter an operator (+.-.*,/,%): "); // Call performOperation method here...
Question 20: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210
Exercise 7: Program exercise for Basic List operations Write a complete Python program including minimal comments (ile name, your name, and problem description) that solves the following problem with the main function: Problem Specification: Write a program that reads a number of scores from the user and performs the following 1. Read scores from the user until the user enters nothing but Center > key 2. Store scores into a list for processing below 3. Find the average of the...
This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...
Do not use pointer variables, pointer arithmetic or operater new ITCS-2530 Project Write an interactive program that performs fractional calculations. You need define a class CFrac for a fractional number according to the UML diagram below: CFrac - numerator : int - denominator : int - simplify () : void + CFrac (int = 0, int = 1) + ~CFrac() + add (const CFrac&) const : CFrac + subtract (const CFrac&) const : CFrac + multiply (const CFrac&)...