Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java programming For this assignment you will create two Java classes each in a separate Java file: 1. The first is the Box class that

java programming image text in transcribed
For this assignment you will create two Java classes each in a separate Java file: 1. The first is the Box class that models a heavy "Box" that should be saved in a file called Box.java. This class should include the following: a. Four private integer instance variables store the Length, Width, Height, and Weight of the Box. Measurements are in feet and pounds. b. Four public methods (setters) to set the value of each of these parameters: setLength, setWidth, setHeight, and set Weight. c. Four public methods (getters) to return the value of each of these parameters: getLength, get Width, getHeight, and get Weight d. Two constructors: Constructor #1 (default constructor) - has no parameters and initializes each of the Box's instance variable to 0. Constructor #2 - that receive four integer parameters that would initialize the Box object's Length, Width, Height, and Weight. c. A method calculateVolume( ) which returns the volume (formula: Length*Width *Height) of the Box object as an integer. f method calculate Density which returns the density of the Box (formula: weight/volume) as a double, check for divide by 0. g. A method called toString that returns all information about a box object as a string in the form of: This Box has: Length = xxx, Width - yyy, Height Volume - ttt Density nnn.dd Xxz, Weight WWW

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions