0

I been trying to import the list in the text file to the word doc, the thing is, is that I can only get the last line on the text imported while I'm missing the rest of the top. Can somebody help please?

import java.util.Scanner;
   import java.io.*;
   import java.util.*;
    public class Lab3{
       public static void main (String [] args) throws Exception {
         int i;
         int j;
         File file = new java.io.File("employeedata.txt");
      //Scanner input = new Scanner(file);
      //create  a scanner for input
         Scanner input = new java.util.Scanner(file);
      //make a string array
         String [][] empId = new String [8][6];
      //a while loop that makes the table
         while(input.hasNext()){
            for(i=0;i<8;i++){
               for(j=0;j<6;j++){
               
                  empId[i][j]= input.next();
               //reads the table from left to right
                  String lastName = input.next();
                  String firstName = input.next();
                  float hour = input.nextFloat();
                  float pay =input.nextFloat();
               //calculations
                  double gross = hour * pay;
                  double federal = gross * (.09 / 100);
                  double state = gross * (.07 / 100);
                  double totalDeductions = federal + state;
                  double net = gross - totalDeductions;
               //displays the results
                 // System.out.println(empId[i][j] + "        " + lastName + "         " + firstName + "        " + hour + "       " + pay + "        " + net);
                  java.io.File output = new java.io.File("payroll.doc");
						java.io.PrintWriter outfile = new java.io.PrintWriter(output);
						outfile.println(empId[i][j] + "        " + lastName + "         " + firstName + "        " + hour + "       " + pay + "        " + net);
						//if(i == 6 && j == 8
						outfile.close();
						
               }
            }
         }
         input.close();
      }
   }

employeedata.txt
1000220 PoppinFresh John 45 13.50
1000221 Jackson Michael 38 8.50
1000222 Smoove Willie 42 15.00
1000223 Rothelisberger Ben 50 17.80
1000224 Gangstalicious Manny 30 6.50
1000225 Nawtinclass Nikki 55 6.55
1000226 Peyatenshun Didnat 16 5.95
1000227 Ovaslept Olivia 13 5.58

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by iamthwee
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.