Question: five students, each having scores for three courses, input the above data from the keyboard (including student ID, name, and score for the three courses) to calculate the average score, store the original data and the calculated average score in the disk file "stud.
Import Java. io. *; import Java. util. *; public class lianxi50 {public static void main (string [] ARGs) {internal Ss = new external (system. in); string [] [] A = new string [5] [6]; for (INT I = 1; I <6; I ++) {system. out. print ("Enter the student ID" + I + "Student:"); A [I-1] [0] = ss. nextline (); system. out. print ("Enter the Student name" + I + ":"); A [I-1] [1] = ss. nextline (); For (Int J = 1; j <4; j ++) {system. out. print ("Enter the student's score" + J + ":"); A [I-1] [J + 1] = Ss. nextline ();} system. out. println ("\ n") ;}// calculate the average float AVG; int sum; For (INT I = 0; I <5; I ++) {sum = 0; for (Int J = 2; j <5; j ++) {sum = sum + integer. parseint (A [I] [J]);} AVG = (float) sum/3; A [I] [5] = string. valueof (avg);} // write the disk file string S1 below; try {file F = new file ("C: \ stud"); If (F. exists () {system. out. println ("file exists");} else {system. out. println ("file does not exist, creating file"); F. createnewfile (); // created if the file does not exist} Bu Fferedwriter output = new bufferedwriter (New filewriter (f); For (INT I = 0; I <5; I ++) {for (Int J = 0; j <6; j ++) {S1 = A [I] [J] + "\ r \ n"; output. write (S1) ;}} output. close (); system. out. println ("data has been written to the drive C file stud! ");} Catch (exception e) {e. printstacktrace ();}}}
[Program 50]