assignment 3

Download Assignment 3

If you can't read please download the document

Upload: kyle-chadee

Post on 27-Sep-2015

1 views

Category:

Documents


0 download

TRANSCRIPT

import java.util.*;import java.io.*;public class Statistics{public static void main(String args[]) throws IO*Exception{Scanner in=new Scanner(new FileReader("c:\Users\luke\Desktop\students.dat")); int count,Hspan,Hmath,Hfren,HEng; double avg,highestAvg; String HName; name=in.nextLine(); Spanish=in.nextInt(); Math=in.nextInt(); French=in.nextInt(); English=in.nextInt(); while(name!='ENDDATA'){count=count+1;if (Spanish>Hspan){Hspan=Spanish;}if (Math>Hmath){Hmath=Math;}if (French>Hfren){Hfren=French;}if (English>HEng){HEng=English;}avg=(Spanish+Math+French+English)/4;if (avg>highestAvg){highestAvg=Avg;HName=name;}System.out.printf("The name of the student is %s,and his/her average is, %3.2f",name,avg);System.out.printf(" the highest student avg in class is,%3.2f",highestAvg);System.out.printf(" the name of the student who attained the higest avg is%s,",Hname);System.out.printf(" the highest scores for each subject is:\nSpanish: %d\nEnglish: %d\nFrench: %d\nMath: %d,",Hspan,HEng,Hfren,Hmath);in.close();}