Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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(+) to positive(+)

A representing the average of two numbers

X representing the maximum of two numbers

M representing the minimum of two numbers

S representing the square of a number

Q indicating the user wants to quit the program

The program reads the user's response into a variable of type char. Using a switch statement, the program determines which method to call to process the user's request. For example, if the user enters +, a method is called which prompts the user to enter two integers. The method then finds the sum of the two integers and the method prints the results of the operation. If the user enters X, a method asks for two integers and finds the larger of the two. If the user enters S, a method asks for one value and finds the square of that value. If the user enters Q, the program stops.

For each calculation performed, the method prints the operation requested, the user's original input, and the result.

Note: All output must be sent to a file

Sample Output:

Operation: addition augend: 25

addend: 35

sum: 60

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_2

Step: 3

blur-text-image_3

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago