need to input values from a text file into an array and count values
hi guys im new to java and i need to input int from a text file into an array and count the values together
heres what i have got so far.
as you can see from the code below the array is called guestNumbers and the int i want to store is i3 then i want to add the values stored in guestNumbers and then divide the result by the length of guestNumbers
Code:
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 count =1;
guestNumbers = new double[count];
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);
int i3=Integer.parseInt(line3);
System.out.println(i + " " + i2 + " " + i3);
count++;
}