Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java please, as files are. 1. Generate random (size: 10) length, width, height and store in the boxes objects array. (already given in sample

In Java please, as files are.

1. Generate random (size: 10) length, width, height and store in the boxes objects array. (already given in sample code files) 2. Do the bubble sort and selection sort. 3. Print the value after sorting. ** While testing your code, comment one sorting function and test the other. Do not run both sort same time, because that way the 2nd sorting function will get sorted array and you can't check if the 2nd sorting is working or not.

Box.java file:

public class Box { // Convert the public variables to private private double length; private double width; private double height; // Complete the bellow constructors public Box() { this.length = 0.0; this.width = 0.0; this.height = 0.0; // Doing the contructors with the setters and getters was pretty simple and self // explanatory, not much deviation form normal } public Box(double length, double width, double height) { this.length = length; this.width = width; this.height = height; } // Write down the set and get methods for all the variables public void setLength(double length) { this.length = length; } public void setWidth(double width) { this.width = width; } public void setHeight(double height) { this.height = height; } public double getLength() { return this.length; } public double getWidth() { return this.width; } public double getHeight() { return this.height; } // Complete the get volume method public double getVolume() { // Volume method simple math, no struggles here return length * width * height; } }

Runner.java file:

import java.io.File; import java.io.FileNotFoundException; import java.util.Random; import java.util.Scanner; 
public class Runner { public static void main(String args[]) throws FileNotFoundException { //This will through an exemption if the file is not found int n= 10; int i=0; // Box class Array Box boxes[] = new Box[n]; Random r = new Random(); while(i                        

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 Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions