Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void avgGroupChange() throws IOException
- {
- System.out.println( "Enter file name: " );
- String filename = scan.nextLine().trim();
- File file = new File( filename );
- Scanner scan2 = new Scanner( file );
- int groups = scan2.nextInt();
- int currentGroup = 0;
- int groupSize = 0;
- int start, end;
- while ( scan2.hasNextLine() )
- {
- int groupSize1 = scan2.nextInt();
- currentGroup++;
- int startSum = 0;
- int endSum = 0;
- for ( int i = 0; i < groupSize1; i++ )
- {
- start = scan2.nextInt();
- end = scan2.nextInt();
- startSum += start;
- endSum += end;
- }
- double startAvg = ( startSum / groupSize1 );
- double endAvg = ( endSum / groupSize1 );
- System.out.println( "Group" + currentGroup + '\t' + groupSize1
- + "subjects" );
- System.out.println( "average starting cholesterol:" + '\t'
- + startAvg );
- System.out.println( "average final cholesterol:" + '\t' + endAvg );
- System.out.println( "change in cholesterol:" + '\t'
- + ( endAvg - startAvg ) );
- }
- System.out.println( "Done with processing." );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement