Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Dr. Java Objective: Write a program where the user enters in information about 5 boxes, and then they are sorted by their volume. Create

In Dr. Java

Objective:

Write a program where the user enters in information about 5 boxes, and then they are sorted by their volume.

Create a class called Box

- This class has four instance variables

- Label: the name of the box

- Length: the length in feet

- Width: the width in feet

- Height: the height in feet

- Assume Length, Width, and Height are all decimal values

- Constructors

- Default

- Parameterized (MUST CHECK FOR VALID VALUES)

- Accessors for every instance variable

- Mutators for every instance variable

- CHECK FOR VALID VALUES!

- Length Width and Height should all be greater than 0

- Other methods

- getVolume: this method returns a decimal value corresponding to its volume. It also has no parameters

- toString: This method returns a string which is made up of the label of the box and its volume

- Create another class called BoxSorter

- This class has a main method

- An array of boxes

- Prompts the user for box information

- Sorts the boxes

- Displays the sorted boxes

Example Dialog:

image text in transcribed

Welcome to the box sorter! Enter the information about boxes and I'll sort them! Enter the label, length, width, and height (all feet) of box 1 Random electronics 2.0 2.0 2.0 Enter the label, length, width, and height (all feet) of box 2 Art supplies 1.0 3.0 1.0 Enter the label, length, width, and height (all feet) of box 3 VideoGames Box 1 4.0 4.0 3.0 Enter the label, length, width, and height (all feet) of box 4 Board Games Box 3 3.0 3.0 2.0 Enter the label, length, width, and height (all feet) of box 5 Imported Cheeses 0.5 0.5 0.25 Sorte Label: Imported Cheeses Volume: 0.0625 Label: Art supplies Volume: 3.0 Label: Random electronics Volume: 8.0 Label: Board Games Box 3 Volume: 18.0 Label: VideoGames Box 1 Volume : 48.0 d boxeS

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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

assess the infl uence of national culture on the workplace

Answered: 1 week ago