Question

1. Prompt the user for one of the arithmetic operators (op): +, -, *,/, or ** 2. Prompt the user for two input integers (a andb) 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number (a) is the left side, the second (b) the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following messages (but not the quotes), including the prompts Start of Calculator Program Enter the desired operation (+,-, *, /, **): Enter the input number: Enter the second input number: “ “<print the calculation>-<result> End of Calculator Program 6. <-this įs a user prompt “ <-also a user prompt user prompt The input operations are expected to be in the set {+,-, *、**). After the prompt, check to be sure hey are one of those. Print (display) an error message if they are not and do not prompt the user for he numbers. The program ends. The input numbers are expected to be integers. Casting the inputs as int will result in an error if a non-integer is entered. If that happens, a program exception occurs and he program ends n displaying <print the calculation> -<result>, use the following examples as a guide (the output hould look like the example sin the second column) Calculation (op, a, b +, 12, 9 The print (displav) output: <print the calculation<result> 12 +9-21 18-26--8 25 * 6 150 96/ 32 = 3.0 5**3- 125 18, 26 *, 25, 6 /, 96, 32 Dont worry about the exact spacing and formatting of the output numbers. The floating point umbers, for example, might have more digits to the right of the decimal point. Well learn how to

0 0
Add a comment Improve this question Transcribed image text
Answer #1

print(Start of Calculator Program) operator-input(Enter the desired operation (+-,*,/, **):) aint(input(Enter the input number: )) b - int(input(Enter the second input number: )) if operator+ elif operator-: elif operator*: print(a, +,b, (a+b)) print (a, - ,b,- (a-b)) print(a,*, b, (a*b)) elif operator print(a,/, b, (a/b)) elif operator**: print (a,**,b,-,(a*b)) else: print(Error! Invalid Operator) print(End of Calculator Program)

Output :

Add a comment
Know the answer?
Add Answer to:
1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or **...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Creating a Calculator Program

    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...

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    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...

  • Write a Java program which allows the user to perform simple tasks on a calculator. A...

    Write a Java program which allows the user to perform simple tasks on a calculator. A series of methods allows the user to select an operation to perform and then enter operands. The first method displays a menu, giving the user the choice of typing in any one of the following: +, -, *, /, or % representing the usual arithmetic operators (Each operation should be done on numbers negative(-) to positive(+), positive(+) to negative(-), negative(-) to negative(-), and positive(+)...

  • This is a quick little assignment I have to do, but I missed alot of class...

    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...

  • Using C Q3. Prompt the user to enter two operands and one operation. Prompt for operation...

    Using C Q3. Prompt the user to enter two operands and one operation. Prompt for operation first -> ‘+’,’-’,’*’ or ‘/’, accept the arithmetic sign for the operation as user’s input and then accordingly specify the types of operands in prompt for operands. Then carry out the operation and print the result. Show two sample outputs in screen captures - one for division and another for any other operation of your choice. Use switch construct. Fill the below blanks -...

  • Write a Java program to prompt for inputting an integer N, then enter N integers (a...

    Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...

  • Pythpn #Exercise 1 #Ask the user for a three letter word using the prompt: three letter...

    Pythpn #Exercise 1 #Ask the user for a three letter word using the prompt: three letter word? (include a space after the ?) #Display the entire word #Display the word vertically, one letter at a time using print statements and the string index #For example, if the user enters baa, the output should be (ignore # signs): #baa #b #a #a #Exercise 2 #Ask the user for a number using the prompt: first number? (include a space after the ?)...

  • Write a program in Java language to prompt the user to enter 3 integers (A, B,...

    Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...

  • Write a c++ complete program to meet the specifications. The program should prompt the user for...

    Write a c++ complete program to meet the specifications. The program should prompt the user for a positive integer. The program should print a message whether the integer is even or odd. The looping should end when the user enters a negative number. The negative number will not be tested for even or odd. The program will print out a message of how many numbers were entered (not counting the negative number) and how many even and odd numbers were...

  • extra credit 1 Write a program that will display the following menu and prompt the user...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT