hi im trying to input values from a txt file gn.txt into an array guestNumber
this is my code so far
Scanner cc = new Scanner( new File("CC.txt") ); Scanner sn = new Scanner( new File("sn.txt") ); Scanner ng = new Scanner( new File("gn.txt") ); String line ; String line2 ; String line3 ; System.out.println("course code"+" " + "Student Number" +" "+"Number of guests"); int lineCount = 0; BufferedReader br2 = new BufferedReader(new FileReader("gn.txt")); while ((line = br2.readLine()) != null) { lineCount++; } System.out.println(lineCount); double guestNumbers[] = new double[lineCount]; for(int c=0; c< lineCount; c++) { double e=Double.parseDouble(br2.readLine()); System.out.println(e); guestNumbers[c]= e; } while( cc.hasNext() && sn.hasNext() && ng.hasNext() ){ line = cc.nextLine(); line2 = sn.nextLine(); line3 = ng.nextLine(); int i=Integer.parseInt(line); int i2=Integer.parseInt(line2); double i3=Double.parseDouble(line3); System.out.println(i + " " + i2 + " " + i3); } System.out.println(guestNumbers[0]); System.out.println(guestNumbers[1]); System.out.println(guestNumbers[2]); System.out.println(guestNumbers[3]); cc.close(); sn.close(); ng.close();
when i run the program im getting a null pointer exception