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

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

  • Complete the Python program below that performs the following operations. First prompt the user to input...

    Complete the Python program below that performs the following operations. First prompt the user to input two integers, n and m. If n<m, then print the odd positive integers that are less than m (in order, on a single line, separated by spaces). If man, then print the even positive integers that are less than n (in order, on a single line, separated by spaces). If neem, then print nothing. For instance, if the user enters 5 followed by 10,...

  • 1. print mesage to user to prompt user to enter 10 numbers 2 have program accept...

    1. print mesage to user to prompt user to enter 10 numbers 2 have program accept 10 numbers from user and populate 10 occurrances of an array (use a loop to do this). 3. print message to user to advise user contents of array follows 4. have program display array contents (use loop to do this) end program comment in java please

  • Complete a partially written C++ program that includes a function that return a value. The program...

    Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...

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
ADVERTISEMENT