Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please.solve my java question Problem #2: (30 pts) Write a program that prompts the user to enter two numbers a and b and an arithmetic

image text in transcribed

please.solve my java question

Problem #2: (30 pts) Write a program that prompts the user to enter two numbers a and b and an arithmetic operator op where op can be * or /. The program then computes the result of a op b. The program should take into account the following cases: If the user enters an invalid operator, the program displays the error message "Invalid operator!". If the user enters the division operator"/" and the denominator bis 0, the program displays the error message "Division by 0 is not allowed!". Sample run 1: Enter two numbers: 15 2 Enter one of the operators (*, 7): / 15.0 / 2.0 = 7.5 Sample run 2 : Enter two numbers: 12 8 Enter one of the operators (*. /): + Invalid operator! Sample run 3: Enter two numbers: 70 Enter one of the operators (*. /): / Division by O is not allowed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Understand why empowerment is so important in many frontline jobs.

Answered: 1 week ago