Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Section 3, P 9. (15 marks) Write a program (without imports) that prompts the user to enter a double value. This double represents the length
Section 3, P 9. (15 marks) Write a program (without imports) that prompts the user to enter a double value. This double represents the length of a side of a cube. The program has a method to compute and return the surface area of a cube (6 x side length x side length), another method to compute and return the volume (side length x side length x side length) and a mairn method to do the rest of the work (prompt the user, call the methods, display the results). Your arca and volumc methods should throw an exception if the argument (side length) is negative - this is an illegal argument. Your main method should catch this exception and any number format exception if the user tries to enter a String when prompted for the side length. The program should continue (prompt, compute, display) until the user enters a side length of O which ends the program *Alternate: Ignore the exceptions above for a maximum of 9 out of 15
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started