title: Floating Decimal, Parsing info from fileread- what is going on
body: <p>okay guys im really really confused and all or any help is appropriated to the MAX! </p>
  
  <p>EDIT: I am working on an assignment that deals with reading data from a text file, and parsing that data to various arrays. i am stuck on parsing, keep receiving a floating decimal error.</p>
  
  <p>This is my first time ever using fileread. im trying to extract the hours and wage from employees and calculate their gross and net pay. Then i wanted to display, in alphabetical order, a managers report of all their information plus my calculated information... 
  i have efficiently wrote a program that displays their information. i cannot, for the life of me, find a way to parse this information to start applying my calculations. first let me show you what i have, then i will show you what i am doing and the results. 
  here is what i have: </p>
  
  <pre><code>import java.awt.HeadlessException;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  import java.text.DateFormat;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  
  
  public class T2 {
  public static void main(String[] args) 
  {
     String list = "";//creates a list for output GUI
     System.out.println("Reading File ......");
     //Name of the file with precise directory
     //String fileName="data.txt"
     String fileName="G:\\cs215\\assign 2\\FileRead\\READTHIS.txt"; //turns a file into string
     //tring fileName="C:\\cs130\\Max_names.txt"; //turns a file into string on my PC
     //Arrays to store variables for each person
     String [] extra = new String [11];
     String [] Name = new String [11];
     String [] familyName = new String [11];
     String [] FName = new String [11];
     String [] credit = new String [11];
     String [] hr = new String [11];
     String [] wg = new String [11];
  
     Double [] wage = new Double [11];
     Double [] hrworked = new Double [11];
  
     try{//Try tests the code inside of it for errors. 
        //Create object of FileReader
        FileReader inputFile = new FileReader(fileName);
        //Instantiate the BufferedReader Class
        BufferedReader bufferReader = new BufferedReader(inputFile);
        //Variable to hold the one line data
        String line = null;
        // Read file line by line and print on the console
        int row = 0;
        while ((line = bufferReader.readLine()) != null)   {
         extra[row]= line;
         row++;        
        }
        //Close the buffer reader
        bufferReader.close();
      //This loop contains and seperates each line into individual words
        for (int y = 0;y&lt;=9;y++)
                {
                   //seperates the first word in each line from the other ones.
        int u = 0;
    while(u &lt; extra[y].length())
    {
       if(extra[y].charAt(u) == ',')//Determines the point at which the words are seperated
       {
           //Splits one word and the remaining words into two variables
         Name[y] = extra[y].substring(0, u);
          familyName[y] = extra[y].substring(u + 1, extra[y].length());
          u = extra[y].length();
       }
       ++u;
    }
    //seperates the second word in each line from the other ones.
    int a = 0;
    while(a &lt; familyName[y].length())
    {
       if(familyName[y].charAt(a) == ',')//Determines the point at which the words are seperated
       {
           //Splits one word and the remaining words into two variables
          FName[y] = familyName[y].substring(0, a);
          credit[y] = familyName[y].substring(a + 1, familyName[y].length());
          a = familyName[y].length();
       }
       ++a;
    }
    //Puts the words back together in re-sorted order
    extra[y] = ("" +FName[y] +", "+Name[y]+", " +credit[y]+ "");
                }//end of sorting and resorting loop
        //places each name in string.
        String[] arr = {extra[0], extra[1], extra[2], extra[3],extra[4], extra[5], extra[6], extra[7], extra[8], extra[9]};
        //rearanges the string in alphabetical order from top to bottom based on last name
  String tmp;
  for (int i = 0;i &lt; arr.length;i++)
  {
    tmp = arr[i];
    for (int j = 0;j &lt; arr.length;j++)
    {
      if (i == j) continue;
      int x = tmp.compareTo(arr[j]);
      if (x &lt; 0)
      {
        tmp = arr[j];
        arr[j] = arr[i];
        arr[i] = tmp;
      }
    }
  }
  //acquires the current date
    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
     Calendar cal = Calendar.getInstance();
  for (int r=0;r&lt;10;r++)
    {
    int pl = 0;
    while(pl &lt; arr[r].length())
    {
       if(arr[r].charAt(pl) == ',')//Determines the point at which the words are seperated
       {
           //Splits one word and the remaining words into two variables
          familyName[r] = arr[r].substring(0, pl);
          Name[r] = arr[r].substring(pl + 1, arr[r].length());
          pl = arr[r].length();
       }
       ++pl;
    }
    //seperates the second word in each line from the other ones.
    int pr = 0;
    while(pr &lt; Name[r].length())
    {
       if(Name[r].charAt(pr) == ',')//Determines the point at which the words are seperated
       {
           //Splits one word and the remaining words into two variables
          FName[r] = Name[r].substring(0, pr);
          credit[r] = Name[r].substring(pr + 1, Name[r].length());
          pr = Name[r].length();
       }
       ++pr;
    }
    //Seperates the last two words in each line
    int pz = 0;
    while(pz &lt; credit[r].length())
    {
       if(credit[r].charAt(pz) == ',')//Determines the point at which the words are seperated
       {
           //Splits one word and the remaining words into two variables
          hr[r] = credit[r].substring(0, pz);
          wg[r] = credit[r].substring(pz + 1, credit[r].length());
          pz = credit[r].length();
       }
       ++pz;
    }}
         //HERE IS WHERE I AM TRYING TO PARSE THE HOURS AND WAGE FROM MY DOC
         //Prompts the JPanel
     JLabel tran = new JLabel("Date: " + dateFormat.format(cal.getTime()) + "");
       JFrame app = new JFrame("Manager Report");
      app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      //Places all the variables in their correct spots
      tran.setBounds(0, 10, 200, 20); // x, y, width, height    x across, y down
      JLabel tlast = new JLabel("Last Name:");
      tlast.setBounds(0, 30, 200, 20);
      JLabel tfirst = new JLabel("First Name:");
      tfirst.setBounds(200, 30, 200, 20);
  JLabel thour = new JLabel("Work hours:");
      thour.setBounds(400, 30, 200, 20);
      JLabel twage = new JLabel("Wage:");
      twage.setBounds(600, 30, 200, 20);
      JLabel Fix = new JLabel("");//This was added to make JPanel stop glitching
      Fix.setBounds(1400, 30, 200, 20);
      /*Goes throughthe list of people and places all the variables in their 
      correct spots. Note that each line output is lower than before.
      */
  
   for (int t=0; t&lt;=9;t++)
      {
      JLabel displaylname = new JLabel(""+familyName[t] +"");
      displaylname.setBounds(0, 50+(20*t), 200, 20);
      JLabel displayfname = new JLabel(""+FName[t]+"");
      displayfname.setBounds(200, 50+(20*t), 200, 20);
  JLabel displayhours = new JLabel(""+hr[t]+"hrs");
      displayhours.setBounds(400, 50+(20*t), 200, 20);
      JLabel displaywage = new JLabel(""+wg[t]+"$ per hr");
      displaywage.setBounds(600, 50+(20*t), 200, 20);
      //The required windows that allow output in the loop
      app.add(displaylname);
      app.add(displayfname);
  app.add(displayhours);
      app.add(displaywage);
      }
      //The required windows that allow output
      app.add(tran);
      app.add(tlast);
      app.add(tfirst);
      app.add(thour);
      app.add(twage);
      app.add(Fix);
      app.setSize(800, 300);
      app.setVisible(true);    
      //window.setLayout(null);
      app.setResizable(false); 
     }//End of try
     //catches the program, terminates it, and sends an error message if an error is encountered
     catch(IOException | HeadlessException e){
        System.out.println("Error while reading file line by line:" + e.getMessage());                      
     }
   }
  }
  </code></pre>
  
  <p>the text doc im extracting from looks like this, firstname,last,hours,wage:</p>
  
  <blockquote>
    <p>Sukken,Dey,45.0,75
    Will,Duke,40,80
    Adam,Kauffman,43,72
    Shaun,Milson,40,65
    Daniel,Jamestone,35,60
    Matthew,Olberg,40,72
    Andrew,Johnson,45,75
    Arron,Winsen,42,70
    Eric,Winsen,40,65
    Mark,Dinger,45,75</p>
  </blockquote>
  
  <p>im trying to parse the information into the double arrays i have defined at the top. I'm implementing these lines of code right before my promps for jpanel. i commented where. </p>
  
  <pre><code>        for(int m=0; m&lt;11; m++)
          {
         hrworked[m]=Double.parseDouble(hr[m]);
         wage[m]=Double.parseDouble(wg[m]);
         System.out.println(wage[m]);
         }
  </code></pre>
  
  <p>i even placed a print line statement to see if the parses are working and it seems like they are until they hit an error. the output results in </p>
  
  <blockquote>
    <p>run:
    Reading File ......
    75.0
    Exception in thread "main" java.lang.NullPointerException
    75.0
    80.0
    60.0
    75.0
    72.0
    65.0
    72.0
    70.0
    65.0
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838)
        at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.lang.Double.parseDouble(Double.java:538)
        at t2.T2.main(T2.java:147)
    C:\Users\Adamska\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
    BUILD FAILED (total time: 0 seconds)</p>
  </blockquote>
  
  <p>it appears to be parsing because it prints out values for each line but it results in an error and im not sure what the cause is. is this an appropriate approach or should i be using something else to parse my values? if someone could explain what is going on and point me in what i need to do id greatly appreciate it</p>