Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Palayiapin Jlyies LUILITY Task02: An orange square is inscribed inside a circle as shown in the diagram below. Write an interactive Java program that prompts
Palayiapin Jlyies LUILITY Task02: An orange square is inscribed inside a circle as shown in the diagram below. Write an interactive Java program that prompts for and reads the area of the square in square centimeters. It then calculates and prints the area of the green part in square centimeters. Your program must catch java.util.Input MismatchException and display an appropriate error message in case such an Exception is thrown. Note: Your program must not use selection statements. Sample program runs: Enter the area of the square [sq cm) : t Error: Invalid input Enter the area of the square (sq cm) : 26.75 Green area = 15.27 square cm Enter the area of the square [sgcm]: 16.0 Green area = 9.13 square cm Enter the area of the square [sg cm] : -56.0 Green area = NaN square cm Note: The last output error is due to passing a negative number to the square root method. This error can be avoided by using selection statement. We will cover selection statements later on in the course
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