Results 1 to 1 of 1
Thread: need help with my output
- 01-22-2011, 08:06 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 14
- Rep Power
- 0
need help with my output
i have program that i want to output a list from text files then do a sum and output the result
Java 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 lineCount = 0; BufferedReader br2 = new BufferedReader(new FileReader("gn.txt")); while ((line = br2.readLine()) != null) { lineCount++; } double guestNumbers[] = new double[lineCount]; String e1; double e; for(int i=0; ng.hasNext();i++){ e1=ng.next(); e=Double.parseDouble(e1); guestNumbers[i]=e; } double total =0; while( ng.hasNext() ){ line = cc.nextLine(); line2 = sn.nextLine(); line3 = ng.nextLine(); int i4=Integer.parseInt(line); int i2=Integer.parseInt(line2); double i3=Double.parseDouble(line3); System.out.println(i4 + " " + i2 + " " + i3); } cc.close(); sn.close(); ng.close(); System.out.println("total number of students attending= " + lineCount); System.out.println("total number of guests attending = " + summ(guestNumbers)); System.out.println("the ratio of students to guests is = " + summ(guestNumbers)/lineCount + " to 1");
the output is
course code Student Number Number of guests
total number of students attending= 4
total number of guests attending = 7.0
the ratio of students to guests is = 1.75 to 1
what i want is
course code Student Number Number of guests
321 123321 1.0
321 654123 2.0
111 652145 3.0
324 545545 1.0
total number of students attending= 4
total number of guests attending = 7.0
the ratio of students to guests is = 1.75 to 1
Similar Threads
-
how to get the resultset output into an output file
By renu in forum New To JavaReplies: 0Last Post: 09-30-2010, 08:16 PM -
Why do I get this output?
By Allspark in forum New To JavaReplies: 3Last Post: 09-23-2010, 08:07 AM -
Where is output.txt?
By Jessaurum in forum New To JavaReplies: 3Last Post: 11-18-2009, 06:14 AM -
Need help: output is not what i want
By Joshsmith in forum New To JavaReplies: 8Last Post: 09-28-2009, 10:09 AM -
Java, output string, getting correct output? HELP!
By computerboyo in forum New To JavaReplies: 2Last Post: 02-25-2009, 11:44 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks