Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called Calculator with the following methods sumRange takes 2 integers, a and b. Input a cannot be negative and must be less

image text in transcribed

Write a class called Calculator with the following methods sumRange takes 2 integers, a and b. Input a cannot be negative and must be less than b. The sum of all the integers from a to b inclusively, is returned. If the input fails to meet the specified criteria return 0 findGreatest takes 3 doubles and returns the double with the greatest value factorial takes an integer and returns a long that represents the factorial of the integer. 5! (say "five factorial") 1*2*3*4*5 120 An input of 0 or less should return 0 Write a testing class called CalculatorTester with the following static method selectionMenu takes a Scanner as input and prints the menu shown below. The methods scans the user input and returns what was scanned Enter your selection: 1: Factorial 2: Sum Range 3: FindGreatest 4: Quit Write a main method that does the following . Creates a Scanner and a Calculator .Calls the selectionMenu method to capture user selection Prompt the user for input depending on selection Uses if statements or a switch call the appropriate Calculator method and print the result If the user inputs an invalid selection, print ERROR Uses a loop to repeat this until the user selects quit Example output for input of 1,4 Enter your selection: 1: Factoria1 2: Sum Range 3: Find Greatest 4: Quit Enter an integer 24

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

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

3. Discuss the process of behavior modeling training.

Answered: 1 week ago