Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete a UML and implementation for class Cube that has a private instance variable side of type int. Provide a default constructor that initializes the

Complete a UML and 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 Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

Students also viewed these Databases questions

Question

Help complete each step

Answered: 1 week ago

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago

Question

1. Discuss the potential legal issues that relate to training.

Answered: 1 week ago

Question

3. Design a program for preparing for cross-cultural assignments.

Answered: 1 week ago