Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

tring to build the program that takes the sphere class layout to be able to create a new sphere Create an Sphere class that has

tring to build the program that takes the sphere class layout to be able to create a new sphere

Create an \"Sphere\" class that has the following: Attributes diameter - double that is the diameter of the sphere color - String that is the color of the sphere finish - String to identify the surface finish of the sphere like \"mirror, shiny, dull, matte, etc...\" Methods Getters and Setters for each attribute Volume - method that returns the volume of the sphere (volume is 4/3 times Pi times radius cubed) SurfaceArea - method that returns the surface area of the sphere (Surface is 4 times Pi times radius squared) NOTE: You should use the static Math Class in java to help with the calculations as it has an attribute \"Pi\" and will allow you to do powers using the \"pow()\" method. Java documentation (Links to an external site.) Some examples using the methods in Math (Links to an external site.) Write a program that employs your \"Sphere\" class and does the following: Creates a sphere based upon user input for the sphere diameter, color and finish You need to use a Scanner to collect the input Write out all of the information on the sphere (attributes, volume and surface area) in a single informational message dialog (using JOptionPane). Make sure to use the getters and methods from your Sphere class for this After this output, creates a 2nd sphere using the default constructor Based upon user input, collected using a JOptionPane input dialog, set the different attribute values for the 2nd sphere based upon that user input Write out all of the information on the 2nd Sphere to the console (terminal window) NOTE: Your program should employ both constructors and each method at least once. This is to ensure that they all work as intended.

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_2

Step: 3

blur-text-image_3

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

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students explore these related Programming questions