Question
box flile public class Box { // Convert the public variables to private public double length; public double width; public double height; //Complete the bellow
box flile
public class Box { // Convert the public variables to private public double length; public double width; public double height; //Complete the bellow constructors public Box() { } public Box(double length, double width, double height) { } // Write down the set and get methods for all the variables public void setLength(double length) { } public void setWidth(double width) { } public void setHeight(double width) { } public double getLength() { return 0; } public double getWidth() { return 0; } public double getHeight() { return 0; } // Complete the get volume method public double getVolume(){ return length*width*height; } }
runner file
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner;
public class Runner { public static void main(String args[]) throws FileNotFoundException { File file = new File("/Users/afarhan/eclipse-workspace/CS2401_LAB3/src/boxfile.txt"); //Creating Scanner instnace to read File Scanner scnr = new Scanner(file); // First line of text file that give us the number of boxes String n_str = scnr.nextLine(); int n = Integer.parseInt(n_str); // Box class Array Box boxes[] = new Box[n]; // Scanning each row of the text file and making boxes with the len,width,height values int i = 0; while(i }
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