Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA, USE SCANNER TO READ THE FILE AND MAKE THE CODE SIMPLE The client will provide data in the form of a text file.

IN JAVA, USE SCANNER TO READ THE FILE AND MAKE THE CODE SIMPLE

The client will provide data in the form of a text file. Some lines at the beginning will contain three numbers separated by spaces representing the width, height, and length of the available size of boxes in the inventory. Note that each of these lines represents a box-type. The ship center has unlimited supplies of any available box-types. The rest of the lines will contain only one number in each line to represent the radius of a basketball. Your task is to find the smallest box-type that can fit a basketball inside it. The word smallest refers to a comparison in terms of the volume of the boxes. Your program must provide the following information as terminal output.

For each of the basketballs, provide the best box-type (that is, the size of the smallest box that can fit the basketball). If there is no box-type that will be able to fit a basketball, print Box not available for this basketball.

For each of the basketballs, provide the volume of the selected box-type, the volume of the basketball, and the volume of the empty space inside the box after placing the basketball. If your answer was Box not available for this basketball then just provide the volume of the basketball.

How many basketballs were you able to fit in the available box-types?

Provide a list of radii of the basketballs that do not fit in any box. Provide a list of box-types (sizes) that were not used at all.

REQUIREMENTS:

You must write and use two classes: BoxType and Basketball. They should be written in two java files: BoxType.java and Basketball.java. The BoxType class will contain the status of the box type (width, height, and length) and other necessary methods. Similarly, the Basketball class will contain the radius of a basketball and other necessary methods.

You must create all the BoxType and Basketball objects in a separate class named MainProg.java that has the main method. Your program must create and use an array of BoxType objects and an array of Basketball objects containing the box-types and basketball information provided in the input file.

You are not allowed to write code to compute the volume of a box-type in the MainProg.java file. You must write the code to compute the volume of a box-type in the BoxType.java file. The BoxType class must contain the following methods:

o double getVolume() : The method will return the volume of a boxtype.

o boolean fitsInBoxType(Basketball b) : The method will return true if the basketball object b fits in a particular type of box, otherwise it will return false. Caution: You will need to compare the diameter, not the radius, of the basketball with the width, height, and length of the box.

o double emptySpace(Basketball b) : The method will return the volume of the empty space in the box after putting the basketball b in it. If the basketball does not fit, the method will return the exact volume of the box-type since the basketball cannot occupy any space of the box.

You are not allowed to write any code to compute the volume of a basketball in the MainProg.java file. You must write it in the Basketball.java file. The Basketball class must contain at least the following method: o double getVolume() : The method will return the volume of the basketball. Consider that each of the basketballs is a sphere with a fixed radius.

Example input file:

2.00 10.00 8.00

4.50 8.45 1.20

8.00 2.50 4.00

0.2 0.1 0.4

3.9 15.00 1.80

6.0 5.0 10.0

2

1

1.9

0.9

2.5

2.49

2.51

3.2

5.0

5.1

2.5

1.2

1.8

2.0

1.85

0.59

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_2

Step: 3

blur-text-image_3

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

Give the major product(s) of the following reaction

Answered: 1 week ago

Question

Diagnose situations to analyze the strength of motivation present.

Answered: 1 week ago