Write a calculator that will give the user this menu options:
1)Add
2)Subtract
3)Multiply
4)Divide
5)Exit
. Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place.
Please answer in python and make it simple. Please implement proper indentation, not just a paragraph of code. Thanks.
|
Example 1: Let's calculate! 1) Add 2) Subtract 3) Multiply 4) Divide 5) Exit Please select one of options above: 4 Enter the first number: 2.81 Enter the second number: 1.111 Answer: 3.1 1) Add 2) Subtract 3) Multiply 4) Divide 5) Exit Please select one of options above: 5 Have a good day! |
while True:
print("Let's calculate!")
print("1) Add")
print("2) Subtract")
print("3) Multiply")
print("4) Divide")
print("5) Exit")
choice = int(input("Please select one of options above: "))
if choice == 5:
print("Have a good day!")
break
n1 = float(input("Enter the first number: "))
n2 = float(input("Enter the second number: "))
if choice == 1:
print("Answer:", n1 + n2)
elif choice == 2:
print("Answer:", n1 - n2)
elif choice == 3:
print("Answer:", n1 * n2)
elif choice == 4:
print("Answer:", n1 / n2)
else:
print("Invalid choice!")
Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit...
IN PYTHON! Create a calculator GUI. The GUI should let the user add, subtract, multiply, and divide two numbers they input. All user input and the result displayed to the user should be seen in the GUI itself (i.e. the terminal should not show anything). Thank you very much! PLEASE PASTE IN HERE THE RIGHT INDENTS
Create a 'simple' calculator. The calculator should be able to add, subtract, multiply, and divide two numbers. You can use whatever format you want to receive the numbers (such as textboxes). You also can use whatever method (such as a button for each operation +, -, *, /) to determine what operation the user wants to accomplish. The output should be displayed in a similar format to "1 + 2 = 3" or "1 - 2 = -1". Make sure...
1.Write a Python program to perform simple arithmetic operations (add, subtract, multiply and divide) on 2 numbers and display the output on console ( use methods in your program) Range of numbers : 1 to 100 (Do not use 0)
Write MIPS code that emulates a simple calculator. The calculator initially has the value 0. Prompt the user to enter a command. A command is a number, where 0 is add, 1 is subtract, 2 is multiply, 3 is divide, 4 is clear, and 5 is exit. When the user enters 0, 1, 2, or 3, prompt the user for a number to add, subtract, multiply or divide from the current value. If the user enters 4, then clear the...
extra credit 1 Write a program that will display the following menu and prompt the user for a selection: A) Add two numbers B) Subtract two numbers C) Multiply two numbers D) Divide two numbers X) Exit program The program should: display a hello message before presenting the menu accept both lower-case and upper-case selections for each of the menu choices display an error message if an invalid selection was entered (e.g. user enters E) prompt user for two numbers...
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator: The calculator has one “accumulator”, which holds the result of all prior calculations. The calculator is set to 0.0 when the calculator is turned on (i.e., instantiated). On the console, the user then enters an operator (+, -, *, or /) and a number. Your console will then apply the operator and operand to the number in the accumulator, and...
Could you code this question on Matlab? :)
Question: Design a GUI based application, named Calculator, which perform basic arithmetic operations ie., add, subtract, multiply, and divide Your design must have 1) Two separate input fields for reading the two operands (let's say a and b) 2) 4 Four button (labeled as +, -, *, /) to let the user select an operation. 3) An output field for displaying the result Following table shows operations performed on pushing each of...
CE – Return and Overload in C++ You are going to create a rudimentary calculator. The program should call a function to display a menu of three options: 1 – Integer Math 2 – Double Math 3 – Exit Program The program must test that the user enters in a valid menu option. If they do not, the program must display an error message and allow the user to reenter the selection. Once valid, the function must return the option...
Can somebody help me with this assignment. I will highly
appreciate. Also, please display the output as well. I need to use
JAVA to to write the program.
This is the sample output provided by my
professor.
HOME WORK: due 09.17.2019 (Rational Numbers) Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private instance variables of the class- the numerator and the denominator. Provide a constructor...
7- (50 points) Write a simple calculator in Python which supports four basic mathematical operators (1.e. + - / *). You need to define a module which supports addition, deletion, multiplication and subtraction. Then import your module to your calculator file and use it in your code. The following example shows how your basic calculator needs to work. Select operation: 1.Add 2.Subtract 3.Multiply 4.Divide Enter your choice(1/2/3/4): 3 Enter first number: 12 Enter second number: 14 12 * 14 =...