Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA CODE REQUIRED implementation for class Cube that has a private instance variable side of type int. Provide a default constructor that initializes the side

JAVA CODE REQUIRED

implementation for class Cube that has a private instance variable side of type int.

  1. Provide a default constructor that initializes the side of the Cube to one
  2. Provide a constructor that initializes the side of the Cube using a parameter.
  3. Provide an accessor method and mutator method. In the mutator method ensure that the side is greater than or equal to 1 using a conditional statement.
  4. Provide a method that computes the surface area of a Cube.
  5. Provide a method that computes the volume of a Cube.
  6. Provide a toString method that will return a String containing the value of side of the cube in the format 0.0.

Implement an application class CubeTest to test the Cube class you defined above. Ensure that all your methods and constructors work properly.

  1. Create a scanner object.
  2. Create a Cube using the default constructor
  3. Prompt user to enter a value for the side of the default Cube and read the side value.
  4. Use the mutator method to change the side of the default Cube.
  5. Create an additional cube object using the parameter constructor.
  6. Create one more cube object using the parameter constructor
  7. get the value of the default Cube side using the accessor method and store in an integer variable.
  8. Print the surface area of one of your Cube Objects (not the default) using the appropriate method.
  9. Print the volume of one of your Cube Object (not the default or the one in used in #7) using the appropriate method.
  10. Print all three Cube Objects using an implicit call to toString.

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

How does your message use nonverbal communication?

Answered: 1 week ago

Question

Define and measure service productivity.

Answered: 1 week ago