With the use of if statements, create a Calculator program that only uses 1 input.
For example, if a person inputs 2 + 3, the program should print 5.
If the person inputs 3 - 1, the program should return 2.
If the person input 4 / 2, the program should return 2.
If the person inputs 3 * 2, the program should return 6.
Python
expression = input("Enter a simple expression: ")
n1 = float(expression.split()[0].strip())
n2 = float(expression.split()[2].strip())
ch = expression.split()[1].strip()
print(expression + " = ", end='')
if ch == '+':
print(n1 + n2)
elif ch == '-':
print(n1 - n2)
elif ch == '*':
print(n1 * n2)
elif ch == '/':
print(n1 / n2)
elif ch == '%':
print(n1 % n2)
elif ch == '**':
print(n1 ** n2)
else:
print('Unknown')
With the use of if statements, create a Calculator program that only uses 1 input. For...
Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...
(COs 1 and 8) Create a Python program that calculates the tip and total for a meal at a restaurant. Paste Python code here; output not required. Sample output: Tip Calculator Enter cost of meal: 52.31 Enter tip percent: 20 Tip amount: 10.46 Total amount: 62.77 Specifications: •Input: costOfMeal, tipPercent The formula for calculating the tip amount is: tip = costOfMeal * (tipPercent / 100) • The program should accept decimal entries like 52.31 and 15.5. • Assume the user...
In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while loop or a for loop to print only odd numbers 1, 3, 5, 7, 9 *tip: you can use range () function, or a condition with ‘break’ (e.g, while count < 10) In python!: Create a program that print out 12 months of a year and associated numbers (e.g., January 1, February 2…). Two lists should be created, and then loop through the list...
# Write PYTHON programs that read a sequence of integer inputs and print # a. The smallest and largest of the inputs. # b. The number of even and odd inputs. # c. Cumulative totals. For example, if the input is 1 7 2 9, the program should print # 1 8 10 19. # d. All adjacent duplicates. For example, if the input is 1 3 3 4 5 5 6 6 6 2, the # program should print...
Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...
create a python program that requests input from the user for a starting and ending value. then your program should return all prime numbers between those two values. you will be using input, conditional and control flow statements
C++ program
Please only (if) (else) statements No while statements use Write a program that takes rate and outputs the employee's wages for the week input employee's hours worked and regular pay as an Calculate employee's wages as follows: She receives her regular rate for the an first 40 hours, 1.5 times her regular rate for each hour between 40 and 50 hours, and double her regular rate for each hour over 50. For invalid inputs, in addition to outputting...
3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...
*Create in Python 3: Change Calculator Create a program that calculates the coins needed to make change for the specified number of cents. Sample Console Output Change Calculator Enter number of cents (0-99): 99 Quarters: 3 Dimes: 2 Nickels: 0 Pennies: 4 Continue? (y/n): y Enter number of cents (0-99): 55 Quarters: 2 Dimes: 0 Nickels: 1 Pennies: 0 Continue? (y/n): n Bye! Specifications The program should display the minimum number of quarters, dimes, nickels, and pennies that one needs...
C PROGRAM HELP create a new file calc.c which implements a simple calculator. The calculator will perform the four basic arithmetic operations +, -, * and /. The program should prompt the user for the operation to perform in an endless loop. For example: calc > 3 + 6 9 calc > You must implement the calculator such that there is one calc function which takes as arguments the numerical values of the two operands and a pointer to the...