Ok, so first off this code is insanely messy and very very long. So if anyone has any ideas on how I can reduce all the variables and make it just run nicer that would be nice.
I have been trying many different types of layouts and saving forms and combined it has just clustered my code quite badly, so any suggestions in that area would help VERY much.

What I need to help with in the source code is this.
1. Need my Report label to display the text in an organized fashion
2. Implement a scrollbar function to appear when the report list is longer than 3, excluding the title row.
3. Make the buttons non expandable, I want them to stay a certain set size.
4. (optional) Find a way to cut down on the amount of variables I have. If you suggest using "this", PLEASE PLEASE PLEASE explain, as that part of Java greatly confuses me.

For the scrollbar, I spent about 2 hours trying to figure it out, and finally just scraped it because I kept getting lost.
I am not lazy and I do not give up, so when i ask for help, its because I honestly do not understand what I am doing, so all help is greatly appreciated.

Here is the source code, I posted the three text files below as well.
To use my program, only the Load and Report buttons work this far. Click LOAD, pick one of my files (I have been using the severalrecords.txt) and then click REPORT.
I need the text label for report to nicely format the information, title row on the top, then each user's data displayed on the next line below.
Once it hits 4 rows, I want the Jscrollbar feature to show up as well.

Again, please EXPLAIN what you all do, because I want to learn. :)

Source Code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.Scanner;

import javax.swing.*;

public class ProjectEngine {

	/*******************************************************************************************
	 * @author Austin Anderson This program will display a Calculator
	 *******************************************************************************************/

	private static JButton buttonLoad;
	private static JButton buttonReport;
	private static JButton buttonMinMPG;
	private static JButton buttonMaxMPG;
	private static JButton buttonAvgMPG;
	private static JLabel Fname1 = new JLabel("");
	private static JLabel Lname1 = new JLabel("");
	private static JLabel Fares1 = new JLabel("");
	private static JLabel GasMoney1 = new JLabel("");
	private static JLabel Miles1 = new JLabel("");
	private static JLabel Gallons1 = new JLabel("");
	private static JLabel MPG1 = new JLabel("");
	private static JLabel Profit1 = new JLabel("");
	private static JLabel Fname2 = new JLabel("");
	private static JLabel Lname2 = new JLabel("");
	private static JLabel Fares2 = new JLabel("");
	private static JLabel GasMoney2 = new JLabel("");
	private static JLabel Miles2 = new JLabel("");
	private static JLabel Gallons2 = new JLabel("");
	private static JLabel MPG2 = new JLabel("");
	private static JLabel Profit2 = new JLabel("");
	private static JLabel Fname3 = new JLabel("");
	private static JLabel Lname3 = new JLabel("");
	private static JLabel Fares3 = new JLabel("");
	private static JLabel GasMoney3 = new JLabel("");
	private static JLabel Miles3 = new JLabel("");
	private static JLabel Gallons3 = new JLabel("");
	private static JLabel MPG3 = new JLabel("");
	private static JLabel Profit3 = new JLabel("");
	private static JLabel Fname4 = new JLabel("");
	private static JLabel Lname4 = new JLabel("");
	private static JLabel Fares4 = new JLabel("");
	private static JLabel GasMoney4 = new JLabel("");
	private static JLabel Miles4 = new JLabel("");
	private static JLabel Gallons4 = new JLabel("");
	private static JLabel MPG4 = new JLabel("");
	private static JLabel Profit4 = new JLabel("");
	private static JLabel Fname5 = new JLabel("");
	private static JLabel Lname5 = new JLabel("");
	private static JLabel Fares5 = new JLabel("");
	private static JLabel GasMoney5 = new JLabel("");
	private static JLabel Miles5 = new JLabel("");
	private static JLabel Gallons5 = new JLabel("");
	private static JLabel MPG5 = new JLabel("");
	private static JLabel Profit5 = new JLabel("");
	private static JLabel Fname6 = new JLabel("");
	private static JLabel Lname6 = new JLabel("");
	private static JLabel Fares6 = new JLabel("");
	private static JLabel GasMoney6 = new JLabel("");
	private static JLabel Miles6 = new JLabel("");
	private static JLabel Gallons6 = new JLabel("");
	private static JLabel MPG6 = new JLabel("");
	private static JLabel Profit6 = new JLabel("");
	private static JLabel Fname7 = new JLabel("");
	private static JLabel Lname7 = new JLabel("");
	private static JLabel Fares7 = new JLabel("");
	private static JLabel GasMoney7 = new JLabel("");
	private static JLabel Miles7 = new JLabel("");
	private static JLabel Gallons7 = new JLabel("");
	private static JLabel MPG7 = new JLabel("");
	private static JLabel Profit7 = new JLabel("");
	private static JLabel Fname8 = new JLabel("");
	private static JLabel Lname8 = new JLabel("");
	private static JLabel Fares8 = new JLabel("");
	private static JLabel GasMoney8 = new JLabel("");
	private static JLabel Miles8 = new JLabel("");
	private static JLabel Gallons8 = new JLabel("");
	private static JLabel MPG8 = new JLabel("");
	private static JLabel Profit8 = new JLabel("");
	private static JLabel start_display = new JLabel("Please load data.");
	private static JLabel report_display = new JLabel("No report data yet.");
	private static JLabel min_display = new JLabel("No minimum data yet.");
	private static JLabel max_display = new JLabel("No maximum data yet.");
	private static JLabel avg_display = new JLabel("No average data yet.");
	static JFrame frame = new JFrame("Welcome!");
	static JPanel panel_startup = new JPanel();
	static JPanel panel_report = new JPanel();
	static JPanel panel_MinMPG = new JPanel();
	static JPanel panel_MaxMPG = new JPanel();
	static JPanel panel_AvgMPG = new JPanel();
	static JPanel panel_top = new JPanel();
	static JPanel panel_middle = new JPanel();
	static JPanel panel_bottom = new JPanel();
	static JPanel panel_main = new JPanel();
	static JPanel panel_upper = new JPanel();
	static Array[] al;
	static String report = "";
	static double mpg1, mpg2, mpg3;
	static double gal1, gal2, gal3;
	static double prof1, prof2, prof3;
	static double mil1, mil2, mil3;
	static double gasM1, gasM2, gasM3;
	static double far1, far2, far3;

	CardLayout ourLayout;

	JPanel scrollPane = new JPanel();

	JScrollPane scroller = new JScrollPane(scrollPane);

	static DecimalFormat dmft = new DecimalFormat("0.00");


	public static void main(String arg[]) {
		ProjectEngine t = new ProjectEngine();
		t.ProjectGUI();

	}

	public void ProjectGUI() {

		panel_startup.setBackground(Color.white);
		panel_startup.setLayout(new GridLayout(1, 5));

		buttonLoad = new JButton("Load");
		buttonLoad.setMaximumSize(new Dimension(1, 1));
		buttonLoad.addActionListener(new e());
		panel_startup.add(buttonLoad);

		buttonReport = new JButton("Report");
		buttonReport.setMaximumSize(new Dimension(1, 1));
		buttonReport.addActionListener(new e());
		panel_startup.add(buttonReport);

		buttonMinMPG = new JButton("Minimum MPG");
		buttonMinMPG.setMaximumSize(new Dimension(1, 1));
		buttonMinMPG.addActionListener(new e());
		panel_startup.add(buttonMinMPG);

		buttonMaxMPG = new JButton("Maximum MPG");
		buttonMaxMPG.setMaximumSize(new Dimension(1, 1));
		buttonMaxMPG.addActionListener(new e());
		panel_startup.add(buttonMaxMPG);

		buttonAvgMPG = new JButton("Average MPG");
		buttonAvgMPG.setMaximumSize(new Dimension(1, 1));
		buttonAvgMPG.addActionListener(new e());
		panel_startup.add(buttonAvgMPG);


		panel_top.setBackground(Color.white);
		panel_top.setLayout(new GridLayout(1, 8));



		panel_middle.setBackground(Color.white);
		panel_middle.setLayout(new GridLayout(8, 8));

		panel_middle.add(Fname1);
		panel_middle.add(Lname1);
		panel_middle.add(Fares1);
		panel_middle.add(GasMoney1);
		panel_middle.add(Miles1);
		panel_middle.add(Gallons1);
		panel_middle.add(MPG1);
		panel_middle.add(Profit1);

		panel_middle.add(Fname2);
		panel_middle.add(Lname2);
		panel_middle.add(Fares2);
		panel_middle.add(GasMoney2);
		panel_middle.add(Miles2);
		panel_middle.add(Gallons2);
		panel_middle.add(MPG2);
		panel_middle.add(Profit2);

		panel_middle.add(Fname3);
		panel_middle.add(Lname3);
		panel_middle.add(Fares3);
		panel_middle.add(GasMoney3);
		panel_middle.add(Miles3);
		panel_middle.add(Gallons3);
		panel_middle.add(MPG3);
		panel_middle.add(Profit3);

		panel_middle.add(Fname4);
		panel_middle.add(Lname4);
		panel_middle.add(Fares4);
		panel_middle.add(GasMoney4);
		panel_middle.add(Miles4);
		panel_middle.add(Gallons4);
		panel_middle.add(MPG4);
		panel_middle.add(Profit4);

		panel_middle.add(Fname5);
		panel_middle.add(Lname5);
		panel_middle.add(Fares5);
		panel_middle.add(GasMoney5);
		panel_middle.add(Miles5);
		panel_middle.add(Gallons5);
		panel_middle.add(MPG5);
		panel_middle.add(Profit5);

		panel_middle.add(Fname6);
		panel_middle.add(Lname6);
		panel_middle.add(Fares6);
		panel_middle.add(GasMoney6);
		panel_middle.add(Miles6);
		panel_middle.add(Gallons6);
		panel_middle.add(MPG6);
		panel_middle.add(Profit6);

		panel_middle.add(Fname7);
		panel_middle.add(Lname7);
		panel_middle.add(Fares7);
		panel_middle.add(GasMoney7);
		panel_middle.add(Miles7);
		panel_middle.add(Gallons7);
		panel_middle.add(MPG7);
		panel_middle.add(Profit7);

		panel_middle.add(Fname8);
		panel_middle.add(Lname8);
		panel_middle.add(Fares8);
		panel_middle.add(GasMoney8);
		panel_middle.add(Miles8);
		panel_middle.add(Gallons8);
		panel_middle.add(MPG8);
		panel_middle.add(Profit8);

		panel_report.setLayout(new FlowLayout());
		panel_report.add(panel_top);
		panel_report.add(panel_middle);
		panel_report.add(panel_bottom);

		panel_top.add(start_display);
		
		panel_main.setLayout(new GridLayout(2, 1));
		panel_main.setBackground(Color.white);
		panel_main.add(panel_top);
		panel_main.add(panel_startup);

		frame.getContentPane().add(panel_main);
		frame.setSize(100, 100);
		frame.pack();
		frame.setVisible(true);
	}

	public class e implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			Object source = e.getSource();

			if (source == buttonLoad) {
				Load();
				Calculations();
			}

			if (source == buttonReport) {
				Report();
			}

			if (source == buttonMinMPG) {

				Min();
			}

			if (source == buttonMaxMPG) {
				Max();
			}

			if (source == buttonAvgMPG) {
				Avg();
			}

		}

	}

private static void ClearAll() {
	report = "";
	start_display.setText("");
	report_display.setText("");
	min_display.setText("");
	max_display.setText("");
	max_display.setText("");
	mpg1 = 0; 
	mpg2 = 0; 
	mpg3 = 0;
	gal1 = 0;
	gal2 = 0;
	gal3 = 0;
	prof1 = 0;
	prof2 = 0;
	prof3 = 0;
	mil1 = 0;
	mil2 = 0;
	mil3 = 0;
	gasM1 = 0;
	gasM2 = 0;
	gasM3 = 0;
	far1 = 0;
	far2 = 0;
	far3 = 0;
}
	
	private static void Load() {
		ClearAll();
		JFileChooser chooser = new JFileChooser();
		Scanner scanner = null;
		int status = chooser.showOpenDialog(null);

		if (status != JFileChooser.APPROVE_OPTION) {
			System.out.println("No file was chosen.");
			return;
		}
		try {
			File file = chooser.getSelectedFile();
			scanner = new Scanner(file);
		} catch (IOException ioe) {
			System.out.println("There was a problem opening the file.");
		}

		while (scanner.hasNext()) {
			Fname1.setText(scanner.next());
			Lname1.setText(scanner.next());
			Fares1.setText(scanner.next());
			GasMoney1.setText(scanner.next());
			Miles1.setText(scanner.next());
			Gallons1.setText(scanner.next());

			Fname2.setText(scanner.next());
			Lname2.setText(scanner.next());
			Fares2.setText(scanner.next());
			GasMoney2.setText(scanner.next());
			Miles2.setText(scanner.next());
			Gallons2.setText(scanner.next());

			Fname3.setText(scanner.next());
			Lname3.setText(scanner.next());
			Fares3.setText(scanner.next());
			GasMoney3.setText(scanner.next());
			Miles3.setText(scanner.next());
			Gallons3.setText(scanner.next());

		}
	}


	private static void Calculations() {
		mil1 = Double.parseDouble(Miles1.getText());
		gal1 = Double.parseDouble(Gallons1.getText());
		mpg1 = mil1 / gal1;
		far1 = Double.parseDouble(Fares1.getText());
		gasM1 = Double.parseDouble(GasMoney1.getText());
		prof1 = far1 - gasM1;
		MPG1.setText(dmft.format(mpg1));
		Profit1.setText(dmft.format(prof1));

		mil2 = Double.parseDouble(Miles2.getText());
		gal2 = Double.parseDouble(Gallons2.getText());
		mpg2 = mil2 / gal2;
		far2 = Double.parseDouble(Fares2.getText());
		gasM2 = Double.parseDouble(GasMoney2.getText());
		prof2 = far2 - gasM2;
		MPG2.setText(dmft.format(mpg2));
		Profit2.setText(dmft.format(prof2));

		mil3 = Double.parseDouble(Miles3.getText());
		gal3 = Double.parseDouble(Gallons3.getText());
		mpg3 = mil3 / gal3;
		far3 = Double.parseDouble(Fares3.getText());
		gasM3 = Double.parseDouble(GasMoney3.getText());
		prof3 = far3 - gasM3;
		MPG3.setText(dmft.format(mpg3));
		Profit3.setText(dmft.format(prof3));

	}


	private static void Report() {

		report = "First Name" + " Last Name" + " Fares" + " Gas Money"
				+ " Miles" + " Gallons" + "  MPG" + " Profit " + "\n"
				+ Fname1.getText() 
				+ Lname1.getText()
				+ Fares1.getText()
				+ GasMoney1.getText()
				+ Miles1.getText()
				+ Gallons1.getText()
				+ MPG1.getText()
				+ Profit1.getText() + " "
				+ "\n"
				+ Fname2.getText()
				+ Lname2.getText()
				+ Fares2.getText()
				+ GasMoney2.getText()
				+ Miles2.getText()
				+ Gallons2.getText()
				+ MPG2.getText()
				+ Profit2.getText() + " "
				+ "\n"
				+ Fname3.getText()
				+ Lname3.getText()
				+ Fares3.getText()
				+ GasMoney3.getText()
				+ Miles3.getText()
				+ Gallons3.getText()
				+ MPG3.getText()
				+ Profit3.getText() 
				+ "\n";
		start_display.setText(report);
		
		System.out.println(report);
	}


	private static void Min() {
		start_display.setText("" + min_display);
	}


	private static void Max() {
		start_display.setText("" + max_display);
	}


	private static void Avg() {
		start_display.setText("" + avg_display);
	}
}

Text files (and yes, the client data is already put on to a newline in the txt file)

OneRecord.txt

John Doe 100.00 20.00 240.00 8.0

SeveralRecords.txt

John Doe 100.00 20.00 240.00 8.0
Roger Ellis 120.00 24.00 250.0 9.0
Larry Smith 130.00 25.00 250.0 7.0

8Records.txt

John Doe 100.00 20.00 240.00 8.0
Roger Ellis 120.00 24.00 250.0 9.0
Larry Smith 130.00 25.00 250.0 7.0
A B 200.00 39.0 300.0 13.0
C D 210.00 40.0 310.0 13.5
E F 220.00 41.0 320.0 14.0
G H 230.00 42.0 330.0 14.5
I J 240.00 43.0 340.0 15.0

Thank you guys sooooooo much in advance!
-Austin

Edited 6 Years Ago by aanders5: n/a

Trust me, I tried doing lots of arrays to keep it clean, but I get really lost. When I do projects I tend to get really over motivated because I love to program and make stuff, but then just end up losing myself in it. lol :/

Imagine, that you have only one line to read from text file.
Write a java console program with the following assumptions:
Open and read text file with fixed name.
Parse values to 6 Local Variables (of String or Double types)
Report on screen.
Variables,Naming http://download.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
...
Create new class ie. Record. Constructor of this class should accept your 6 variables.
Write for this class method report(), without any additional calculations.
Invoke this method. http://download.oracle.com/javase/tutorial/java/javaOO/constructors.html http://download.oracle.com/javase/tutorial/java/javaOO/objectcreation.html
...
Show your code

Since people are finally replying, I will inform you that I have modified this code VERY much since posted yesterday...

I still need a JScroll feature for the top section of the GUI though and for the JLabel to separate the client information onto new lines.
(And no, the "\n" does not work, because when you move the string to the JLabel with setText, it does not print new lines, the JLabel will only display it as one massive line.)

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Scanner;

import javax.swing.*;

public class ProjectEngine {

	/*******************************************************************************************
	 * @author Austin Anderson This program will choose a file,
	 *         calculate the data then allow the user to see a full
	 *         report, as well as the minimum, maximum, and average
	 *         miles per gallon within the report.
	 *******************************************************************************************/

	private static JButton buttonLoad, buttonReport, buttonMinMPG,
			buttonMaxMPG, buttonAvgMPG, buttonExit;

	private static JLabel start_display = new JLabel(
			"Please load data.", JLabel.CENTER);

	static JFrame frame = new JFrame("Welcome!");

	static JPanel panel_buttons = new JPanel();

	static JPanel panel_top = new JPanel();

	static JPanel panel_main = new JPanel();

	static ArrayList<String> al = new ArrayList<String>();

	static ArrayList<Double> calc = new ArrayList<Double>();

	static String report = "";

	static double min, max, avg;

	static int tracker = 0;

	static File file;

	static DecimalFormat dmft = new DecimalFormat("0.00");

	Dimension d = new Dimension(650, 150);

	Dimension b = new Dimension(600, 50);


	public static void main(String arg[]) {
		ProjectEngine t = new ProjectEngine();
		t.ProjectGUI();

	}


	public void ProjectGUI() {

		panel_buttons.setBackground(Color.white);
		panel_buttons.setLayout(new GridLayout(2, 5, 3, 3));
		panel_buttons.setSize(b);

		buttonMaxMPG = new JButton("Maximum MPG");
		buttonMaxMPG.addActionListener(new e());
		panel_buttons.add(buttonMaxMPG);

		buttonAvgMPG = new JButton("Average MPG");
		buttonAvgMPG.addActionListener(new e());
		panel_buttons.add(buttonAvgMPG);

		buttonMinMPG = new JButton("Minimum MPG");
		buttonMinMPG.addActionListener(new e());
		panel_buttons.add(buttonMinMPG);

		buttonLoad = new JButton("Load");
		buttonLoad.addActionListener(new e());
		panel_buttons.add(buttonLoad);

		buttonReport = new JButton("Report");
		buttonReport.addActionListener(new e());
		panel_buttons.add(buttonReport);

		buttonExit = new JButton("Exit");
		buttonExit.addActionListener(new e());
		panel_buttons.add(buttonExit);

		panel_buttons.setBorder(BorderFactory.createLineBorder(
				Color.black, 1));
		panel_buttons.setBackground(Color.black);

		panel_top.setBackground(Color.white);
		panel_top.add(start_display);
		panel_top
				.setBorder(BorderFactory.createLineBorder(Color.black));

		panel_main.setLayout(new GridLayout(2, 1));
		panel_main.setBackground(Color.white);
		panel_main.add(panel_top);
		panel_main.add(panel_buttons);
		panel_main.setBorder(BorderFactory.createLineBorder(
				Color.black, 2));

		frame.setResizable(false);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(panel_main);
		frame.pack();
		frame.setSize(d);
		frame.setVisible(true);
	}

	public class e implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			Object source = e.getSource();

			if (source == buttonLoad) {
				Load();

			}

			if (source == buttonReport) {
				Report();
			}

			if (source == buttonMinMPG) {

				Min();
			}

			if (source == buttonMaxMPG) {
				Max();
			}

			if (source == buttonAvgMPG) {
				Avg();
			}

			if (source == buttonExit) {
				System.exit(1);
			}

		}

	}


	private static void ClearAll() {
		report = "";
		start_display.setText("Loading file...");
		tracker = 0;
		al.clear();
		calc.clear();
	}


	private static void Load() {

		ClearAll();
		Files();
		Calculations();
		start_display.setText("File sucessfully loaded.");
	}


	private static void Files() {
		JFileChooser chooser = new JFileChooser();
		Scanner scanner = null;
		int status = chooser.showOpenDialog(null);

		if (status != JFileChooser.APPROVE_OPTION) {
			System.out.println("No file was chosen.");
			return;
		}
		try {
			file = chooser.getSelectedFile();
			scanner = new Scanner(file);
		} catch (IOException ioe) {
			System.out.println("There was a problem opening the file.");
		}

		while (scanner.hasNext()) {

			al.add(scanner.next());

		}
	}


	private static void Calculations() {

		if (al.size() == 6) {

			calc.add(Double.parseDouble(al.get(4)));
			calc.add(Double.parseDouble(al.get(5)));
			calc.add(calc.get(0) / calc.get(1));
			calc.add(Double.parseDouble(al.get(2)));
			calc.add(Double.parseDouble(al.get(3)));
			calc.add(calc.get(3) - calc.get(4));
			al.add(6, dmft.format(calc.get(2)));
			al.add(7, dmft.format(calc.get(5)));
			al.add(8, "\n");

			max = Double.parseDouble(dmft.format(calc.get(2)));
			min = Double.parseDouble(dmft.format(calc.get(2)));
			avg = Double.parseDouble(dmft.format(calc.get(2)));
		}
		if (al.size() == 18) {
			calc.add(Double.parseDouble(al.get(4)));
			calc.add(Double.parseDouble(al.get(5)));
			calc.add(calc.get(0) / calc.get(1));
			calc.add(Double.parseDouble(al.get(2)));
			calc.add(Double.parseDouble(al.get(3)));
			calc.add(calc.get(3) - calc.get(4));
			al.add(6, dmft.format(calc.get(2)));
			al.add(7, dmft.format(calc.get(5)));
			al.add(8, "\n");

			max = Double.parseDouble(dmft.format(calc.get(2)));
			min = Double.parseDouble(dmft.format(calc.get(2)));
			avg = Double.parseDouble(dmft.format(calc.get(2)));

			calc.add(Double.parseDouble(al.get(13)));
			calc.add(Double.parseDouble(al.get(14)));
			calc.add(calc.get(6) / calc.get(7));
			calc.add(Double.parseDouble(al.get(11)));
			calc.add(Double.parseDouble(al.get(12)));
			calc.add(calc.get(9) / calc.get(10));
			al.add(15, dmft.format(calc.get(8)));
			al.add(16, dmft.format(calc.get(11)));
			al.add(17, "\n");

			if (calc.get(8) > max) {
				max = Double.parseDouble(dmft.format(calc.get(8)));
			}
			if (calc.get(8) < min) {
				min = Double.parseDouble(dmft.format(calc.get(8)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(8)))) / 2;

			calc.add(Double.parseDouble(al.get(22)));
			calc.add(Double.parseDouble(al.get(23)));
			calc.add(calc.get(12) / calc.get(13));
			calc.add(Double.parseDouble(al.get(20)));
			calc.add(Double.parseDouble(al.get(21)));
			calc.add(calc.get(15) / calc.get(16));
			al.add(24, dmft.format(calc.get(14)));
			al.add(25, dmft.format(calc.get(17)));
			al.add(26, "\n");
			if (calc.get(14) > max) {
				max = Double.parseDouble(dmft.format(calc.get(14)));
			}
			if (calc.get(14) < min) {
				min = Double.parseDouble(dmft.format(calc.get(14)));
			}
			avg = (avg + Double.parseDouble(dmft.format(calc.get(14)))) / 2;
		}
		if (al.size() == 48) {
			calc.add(Double.parseDouble(al.get(4)));
			calc.add(Double.parseDouble(al.get(5)));
			calc.add(calc.get(0) / calc.get(1));
			calc.add(Double.parseDouble(al.get(2)));
			calc.add(Double.parseDouble(al.get(3)));
			calc.add(calc.get(3) - calc.get(4));
			al.add(6, dmft.format(calc.get(2)));
			al.add(7, dmft.format(calc.get(5)));
			al.add(8, "\n");

			max = Double.parseDouble(dmft.format(calc.get(2)));
			min = Double.parseDouble(dmft.format(calc.get(2)));
			avg = Double.parseDouble(dmft.format(calc.get(2)));

			calc.add(Double.parseDouble(al.get(13)));
			calc.add(Double.parseDouble(al.get(14)));
			calc.add(calc.get(6) / calc.get(7));
			calc.add(Double.parseDouble(al.get(11)));
			calc.add(Double.parseDouble(al.get(12)));
			calc.add(calc.get(9) / calc.get(10));
			al.add(15, dmft.format(calc.get(8)));
			al.add(16, dmft.format(calc.get(11)));
			al.add(17, "\n");

			if (calc.get(8) > max) {
				max = Double.parseDouble(dmft.format(calc.get(8)));
			}
			if (calc.get(8) < min) {
				min = Double.parseDouble(dmft.format(calc.get(8)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(8)))) / 2;

			calc.add(Double.parseDouble(al.get(22)));
			calc.add(Double.parseDouble(al.get(23)));
			calc.add(calc.get(12) / calc.get(13));
			calc.add(Double.parseDouble(al.get(20)));
			calc.add(Double.parseDouble(al.get(21)));
			calc.add(calc.get(15) / calc.get(16));
			al.add(24, dmft.format(calc.get(14)));
			al.add(25, dmft.format(calc.get(17)));
			al.add(26, "\n");
			if (calc.get(14) > max) {
				max = Double.parseDouble(dmft.format(calc.get(14)));
			}
			if (calc.get(14) < min) {
				min = Double.parseDouble(dmft.format(calc.get(14)));
			}
			avg = (avg + Double.parseDouble(dmft.format(calc.get(14)))) / 2;

			calc.add(Double.parseDouble(al.get(31)));
			calc.add(Double.parseDouble(al.get(32)));
			calc.add(calc.get(18) / calc.get(19));
			calc.add(Double.parseDouble(al.get(29)));
			calc.add(Double.parseDouble(al.get(30)));
			calc.add(calc.get(21) / calc.get(22));
			al.add(33, dmft.format(calc.get(20)));
			al.add(34, dmft.format(calc.get(23)));
			al.add(35, "\n");

			if (calc.get(20) > max) {
				max = Double.parseDouble(dmft.format(calc.get(20)));
			}
			if (calc.get(20) < min) {
				min = Double.parseDouble(dmft.format(calc.get(20)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(20)))) / 2;

			calc.add(Double.parseDouble(al.get(40)));
			calc.add(Double.parseDouble(al.get(41)));
			calc.add(calc.get(24) / calc.get(25));
			calc.add(Double.parseDouble(al.get(38)));
			calc.add(Double.parseDouble(al.get(39)));
			calc.add(calc.get(27) / calc.get(28));
			al.add(42, dmft.format(calc.get(26)));
			al.add(43, dmft.format(calc.get(29)));
			al.add(44, "\n");
			if (calc.get(26) > max) {
				max = Double.parseDouble(dmft.format(calc.get(26)));
			}
			if (calc.get(26) < min) {
				min = Double.parseDouble(dmft.format(calc.get(26)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(26)))) / 2;

			calc.add(Double.parseDouble(al.get(49)));
			calc.add(Double.parseDouble(al.get(50)));
			calc.add(calc.get(30) / calc.get(31));
			calc.add(Double.parseDouble(al.get(47)));
			calc.add(Double.parseDouble(al.get(48)));
			calc.add(calc.get(33) / calc.get(34));
			al.add(51, dmft.format(calc.get(32)));
			al.add(52, dmft.format(calc.get(35)));
			al.add(53, "\n");
			if (calc.get(32) > max) {
				max = Double.parseDouble(dmft.format(calc.get(32)));
			}
			if (calc.get(32) < min) {
				min = Double.parseDouble(dmft.format(calc.get(32)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(32)))) / 2;

			calc.add(Double.parseDouble(al.get(58)));
			calc.add(Double.parseDouble(al.get(59)));
			calc.add(calc.get(36) / calc.get(37));
			calc.add(Double.parseDouble(al.get(56)));
			calc.add(Double.parseDouble(al.get(57)));
			calc.add(calc.get(39) / calc.get(40));
			al.add(60, dmft.format(calc.get(38)));
			al.add(61, dmft.format(calc.get(41)));
			al.add(62, "\n");
			if (calc.get(38) > max) {
				max = Double.parseDouble(dmft.format(calc.get(38)));
			}
			if (calc.get(38) < min) {
				min = Double.parseDouble(dmft.format(calc.get(38)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(38)))) / 2;

			calc.add(Double.parseDouble(al.get(67)));
			calc.add(Double.parseDouble(al.get(68)));
			calc.add(calc.get(42) / calc.get(43));
			calc.add(Double.parseDouble(al.get(65)));
			calc.add(Double.parseDouble(al.get(66)));
			calc.add(calc.get(45) / calc.get(46));
			al.add(69, dmft.format(calc.get(44)));
			al.add(70, dmft.format(calc.get(47)));
			al.add(71, "\n");
			if (calc.get(44) > max) {
				max = Double.parseDouble(dmft.format(calc.get(44)));
			}
			if (calc.get(44) < min) {
				min = Double.parseDouble(dmft.format(calc.get(44)));
			}

			avg = (avg + Double.parseDouble(dmft.format(calc.get(44)))) / 2;
		}
		al.add(0, "First Name");
		al.add(1, "Last Name");
		al.add(2, "Fares");
		al.add(3, "Gas Money");
		al.add(4, "Miles");
		al.add(5, "Gallons");
		al.add(6, "MPG");
		al.add(7, "Profit");
		al.add(8, "\n");

	}


	private static void Report() {

		if (al.size() > 0) {
			report = al.toString().replace(",", "").replace("[", "")
					.replace("[", "");

		} else {
			report = "No file selected yet";
		}
		start_display.setText(report);
	}


	private static void Min() {
		if (al.size() > 0) {

			start_display.setText("The minimum MPG is: "
					+ dmft.format(min));
		} else {
			start_display.setText("No file selected yet");
		}
	}


	private static void Max() {
		if (al.size() > 0) {
			start_display.setText("The maximum MPG is: "
					+ dmft.format(max));
		} else {
			start_display.setText("No file selected yet");
		}
	}


	private static void Avg() {
		if (al.size() > 0) {
			start_display.setText("The average MPG is: "
					+ dmft.format(avg));
		} else {
			start_display.setText("No file selected yet");
		}
	}
}
This article has been dead for over six months. Start a new discussion instead.