Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRTE JAVA CODE Aim: Understanding the methods. 1. Implement a sample program to provide its users with the following operations of a scientific calculator:

image text in transcribedPLEASE WRTE JAVA CODE

Aim: Understanding the methods. 1. Implement a sample program to provide its users with the following operations of a scientific calculator: power, square root, maximum, and logarithm. In your source code, you are not expected to define new methods for these operations. You will just define a main method in a sample class. In main, use switch-case (or if-else) statements to select the operations. First of all, print out the menu (the list of options from which the user can choose), then read the user's choice for the operation and read also the related argument values of the operation, then call the corresponding method of class Math to compute the result of the operation, and finally print out the result. By the way, use an infinite loop in your program and terminate it upon the user's related choice. In order to handle the scientific calculator operations, you are supposed to call the corresponding static methods provided by class Math. The corresponding methods for this Lab work are the following ones: pow, sqrt, max, and log. These methods take double parameters and return double. Some methods of class Math are briefly described below: Method Description exp(a) Natural number e raised to the power of a. log(a) Natural logarithm (base e) of a. floor(a) The largest whole number less than or equal to a max(a,b) The larger of a and b. pow(a,b) The number a raised to the power of b. sqrt(a) The square root of a sin(a) The sine of a. (Note: all trigonometric functions are computed in radians) Please consider the following sample menu displayed at the beginning of the program: A sample scientific calculator is running now ... Here are the menu options for your choice [1 through 5] : *** Press 1 to calculate POWER *** *** Press 2 to calculate SQUARE ROOT *** *** Press 3 to calculate MAXIMUM *** Press 4 to calculate LOGARITHM *** Press 5 to TERMINATE the program *** Your choice

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions