Post a New Question


posted by .

Design a sub-class of SimpleCalculator called Calculator using psudoecode that contains public methods named multiply(), and divide() and that defines private fields called num1 and num2. Each of the methods accepts two numeric arguments and returns a number that represents the result of the appropriate Calculator operation. Design a two-arg constructor Calculator() that sets the two values num1 and num2. Design a main() method that prompts the user for two numbers and reads them in. Then creates an instance of the Calculator class setting the input values via the Calculator constructor. The main() method then tries each of the four arithmetic methods. Assume that an CalculatorException is created and thrown if the user attempts to divide by 0. Display an appropriate message when an exception is caught. If no exception, display the results from each arithmetic method call.

Answer This Question

First Name:
School Subject:

Related Questions

More Related Questions

Post a New Question