Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Important Note: Please follow the java coding style. Comment your code. Maintain indentation. 10% of this lab assignment is reserved for coding style and documentation.

image text in transcribed

Important Note: Please follow the java coding style. Comment your code. Maintain indentation. 10% of this lab assignment is reserved for coding style and documentation. For both of the following problems write your own exception class InvalidInputException that extends the Exception class. The class should have one constructor that does not take any parameter and prints only Invalid input!" and another constructor that takes the invalid input as parameter to show it with the error message. Example: "You provided 3N which is not a valid nput Problem 1: Write a program in java that takes a double value as input from user and prints the square of it. Add appropriate exception handling code block in case the user provides any string other than a double value Sample dialogue: Enter a number: 3.2 The square of the number is: 10.24 Enter a number: 3N The value you provided is invalid Problem 2: Write a program in java that asks user to enter a whole number and keeps asking in case user enters wrong input. Input checking should be done within try/catch block. Sample dialogue: Enter a whole number: forty two Incorrect input. Please try again! Enter a whole number: fortytwo Incorrect input. Please try again! Enter a whole number: 42 You entered: 42

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

More Books

Students also viewed these Databases questions

Question

Question How are IRAs treated for state tax law purposes?

Answered: 1 week ago