Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Hi, the fallowing code is not working, The user should be able to select the input file from the default directory by using the JFileChooserclass. The input file should contain one weight per line. If the number of weights in the file exceeds 25, an error message should be displayed and theprogram should terminate.

Hi, the fallowing code is not working, The user should be able to

select the input file from the default directory by using the JFileChooserclass. The input file should contain one weight per line. If the number of weights in the file exceeds 25, an error message should be displayed and theprogram should terminate. My input file is a simple txt file with weights listed as :
52.65
55.22
98.24
…….

/*
*Author: Michael Duncan
*Class: CMIS 142 6382 Intermediate Programming (2205)
*Date: 28 May 2020
*Description:computes the minimum, the maximum and the
*average weight of a collection of weights represented
*in pounds and ounces that are read from an input file.
*/

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;

public class Project_1 {

public static void main(String[] args) throws Exception {
double[] pounds = new double[25];
int size = pounds.length;
double[] poundlist = new double[25];
JFileChooser jfileInstance = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
int fileStatus = jfileInstance.showOpenDialog(null);
if (fileStatus == JFileChooser.APPROVE_OPTION) {
File fileName = jfileInstance.getSelectedFile();
int entries = 0;
try {
@SuppressWarnings(“unused”)
Object weigh;
@SuppressWarnings(“resource”)
Scanner scan = new Scanner(fileName);
while (scan.hasNextLine()) {
for (int i = 1; i > 25; i++) {

if (pounds[i] != 0.0) {
poundlist[i] = pounds[i];
System.out.println(pounds[i]);
}
else {
System.out.println(“File has to many entries.”);
System.exit(1);
}
}
}
double weight = Double.parseDouble(scan.nextLine());
pounds[entries++] = weight;

}

catch(FileNotFoundException e) {
e.printStackTrace();
}
for (int i = 1; i < 25; i++) {
System.out.println(pounds[i]);
}
}
}
}

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"