Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class, every field, every constructor, and every method

Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class, every field, every constructor, and every method have a general (useful) comment and all relevant tags. This includes @param tags for method and constructors and @param and @return tags for methods. Create a Cube class with the following: 1 data member: an integer named lengthOfSide 2 constructors: a no-argument constructor that set lengthOfSide to 1 and one that takes lengthOfSide as an argument A getter and a setter for lengthOfSide A toString() method for Cube that simply returns the string "Cube: [lengthOfSide]" A getSurfaceArea() method that returns the surface area of this cube. A getVolume() method that returns the volume of this cube. Make sure to Javadoc EVERYTHING! Create a Sphere class that has everything that the cube class has except: Instead of lengthOfSide, Sphere has radius. Note that if you choose to copy and paste, nearly everything will change because of radius Make sure to Javadoc EVERYTHING! This means that if you copy and paste from Cube, there should be no mention of Cube or lengthOfSide in the javadoc. Create a third class named Program4 which has a main method. It should make use of Cube and Sphere to do the following: Create a Scanner named scanner off of standard input. Create a Cube named firstCube and use the default (no-argument) constructor to populate the reference Print out firstCube Prompt the user with "Please enter the length of the side for firstCube: " Read in the next integer and use it to set the length of the side of firstCube. DO NOT USE A CONSTRUCTOR. Make new Cubes named secondCube and thirdCube with sides equal to 8 and 3 respectively Make a new integer named accessorValue and have it store the getter value for firstCube. Output "First Cube side length: ", "Second Cube surface area: ", and "Third Cube volume: " along with their values (use accessorValue for First Cube) Output all three Cubes in order along with the labels "First Cube: ", "Second Cube: ", and "Third Cube: " in the appropriate places. Then print out a new line Repeat steps 1-9 above for Spheres. Change all variable names and all prompts and outputs so that they make sense. Remember to Javadoc Program4 and the main method!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions