Java Reference
In-Depth Information
iii. Print the results for group 1 (call the method
printResult and pass the appropriate parameters).
iv. Print the results for group 2 (call the method
printResult and pass the appropriate parameters).
v. Update the average for group 1.
vi. Update the average for group 2.
vii.
Increment the number of courses.
}
8. a. if not_end_of_file on group 1 and end_of_file on group 2
print ''Ran out of data for group 2 before group 1''
b. else if end_of_file on group 1 and not_end_of_file on
group 2
print ''Ran out of data for group 1 before group 2''
c. else
print the average of group 1 and group 2.
9. Close the files.
COMPLETE PROGRAM LISTING
//*********************************************************
// Author: D.S. Malik
//
// Program: Comparison of Class Averages
// This program computes and compares the class averages of
// two groups of students.
//**********************************************************
import java.io.*;
import java.util.*;
public class DataComparison
{
public static void main (String[] args)
throws FileNotFoundException
{
//Step 1
String courseId1;
//course ID for group 1
String courseId2;
//course ID for group 2
int numberOfCourses;
double avg1; //average for a course in group 1
double avg2; //average for a course in group 2
double avgGroup1;
//average group 1
double avgGroup2;
//average group 2
Search WWH ::




Custom Search