Trouble with a programming assignment Farm production
<p>Develop a top-down design and write a program to produce a bar chart of gourmet-popcorn production for a cooperative farm group on a farm-by-farm basis. </p>

<ul>
<li>The input to the program is a series of data sets, one per line, with
each set representing the production for one farm.</li>
<li>Each data set consists of the name of a farm. Followed by a comma and
one or more spaces, a decimal number representing acres planted, one
or more spaces, and an integer representing the number of pint jars
of popcorn produced for that farm.</li>
<li>The output is a bar chart that identifies each farm and displays its
production in pints of corn per acre.</li>
<li>The output is a single line for each farm, with the name of the farm
starting in the first column on a line and the bar chart starting in
column 30. Each mark in the bar chart represents 25 pint jars of
popcorn per acre.</li>
<li>The production goal for the year is 500 jars per acre. A vertical bar
should appear in the chart for farms with production that does not
meet this goal, and a special mark is used for farms with production
greater than or equal to 500 jars per acre.</li>
</ul>

<p><strong>For example, given the input file</strong></p>

<pre><code>Orville’s Acres, 114.8 43801
Hoffman’s Hills, 77.2 36229
Jiffy Quick Farm, 89.4 24812
Jolly Good Plantation, 183.2 104570
Organically Grown Inc., 45.5 14683
</code></pre>

<p>the output would be:</p>

<pre><code>Popcorn Co-op
Production in Hundreds
of Pint Jars per Acre
Farm Name 1 2 3 4 5 6
---|---|---|---|---|---|
Orville's Acres *************** |
Hoffman's Hills ****************** |
Jiffy Quick Farm *********** |
Jolly Good Plantation *******************#**
Organically Grown Inc. ************ |
</code></pre>

<p>This is the code I have already it runs and prints the correct format but it has an exception error. I am trying to split a string up into the farm name then a double acres and finally a int jars. The input file is </p>

<pre><code>Orville’s Acres, 114.8  43801
Hoffman’s Hills, 77.2  36229
Jiffy Quick Farm,       89.4  24812
Jolly Good Plantation,  183.2  104570
Organically Grown Inc., 45.5        14683
</code></pre>

<p>The reason for all the spaces is I want it just to read lines with data. </p>

<p>Here is my source code</p>

<pre><code>import java.util.Scanner;
import java.io.*;

public class Popcorn
{

public static void main(String args[])throws Exception
{

    printHeading(); 

    System.out.print("Input file name you want to read from: ");

    Scanner in = new Scanner(System.in);    

    String fileName = in.next();    //declares fileName a string that uses in as input

    Scanner input = new Scanner(new FileReader(fileName));  //Declares input as the fileName and reads the file in

    int jars;
    double acres;
    String amount;
    String farmName;
    System.out.println();
    System.out.println("\t\t\tPopcorn Co-op");
    System.out.println();
    System.out.println("\t\t\t\tProduction in Hundreds");
    System.out.println("\t\t\t\tof Pint Jars per Acre");
    System.out.println("Farm Name\t\t\t   1   2   3   4   5   6");
    System.out.println("\t\t\t\t---|---|---|---|---|---|");


    while (input.hasNextLine())
    {


        String inputLine = input.nextLine();    

        if (inputLine.isEmpty())
        {   

        }
        else 
        {
            farmName = inputLine.substring(0,inputLine.indexOf(','));
            String inputLine2 =  inputLine.substring(inputLine.indexOf(','),inputLine.length());
            Scanner line = new Scanner(inputLine2);
            acres = line.nextDouble();
            jars = line.nextInt();
            System.out.println(farmName + jars + acres);

        }

    }
}

private static void printHeading(){


    System.out.println("Name");  //this assigns what printHeading will print
    System.out.println("CSC 201-55468 Section 01PR");
    System.out.println("Fall 2012");
    System.out.println("Popcorn Project");
    System.out.println();
    }

}
</code></pre>
