Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class called Cuboid. A Cuboid is described by three pieces of private information as instance variables: width, length, Height and height. All are
Create a class called Cuboid. A Cuboid is described by three pieces of private information as instance variables: width, length, Height and height. All are double. Provide a set and a get method for each instance variable. The setters must ensure that the values are positive. Your class should have a constructor that properly initializes the three instance variables. Add a no-arguments constructor that sets width = 1, length = 2, height = Width Length In addition, provide the following methods: 1. A method named calculate Area) that returns the area calculated based on the following formula: Area = 2 x (length x width + length x height + width x height) 2. A method named calculate Volumed that returns the volume calculated based on the following formula: Volume = length x width x height Write an application named CuboidTest to test Cuboid class. In the CuboidTest do the following: 1. Create two cuboid instances using the different constructors. 2. Using a Scanner, create another cuboid object with user input values. 3. Print the details of all cuboids. Submission Instructions Rename this file to "251InLabAssignl - B56 - Your name Solution: Cuboid.java class CuboidTest.java class Screenshot of Output
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