This article shares with you the Java implementation of student score entry system for your reference. The specific content is as follows
1. Student category, including the student’s name and grades of each subject
public class Score { public String name; public double EnglishGrade, MathGrade,phyicalGrade,chemicalGrade,biologicalGrade; Score() { } public Score(String name,double EnglishGrade, double MathGrade,double physicalGrade, double chemicalGrade,double biologicalGrade){ this.name = name; this.EnglishGrade = EnglishGrade; this.MathGrade = MathGrade; this.phyicalGrade = physicalGrade; this.chemicalGrade = chemicalGrade; this.biologicalGrade = biologicalGrade; } }2. Set up the student class, including setting and searching, etc.
package score; public class ScoreZip { Score[] S = new Score[5]; public void setData(Score name, int index) {//Add grade class to score array S[index] = name; } public Score[] getData() { //Return the student array return S; } public Score SerchData(String name) { //Find the student scores for (int index = 0; index < S.length; index++) { if (name !=null && S[index] != null ) if (S[index].name.equals(name)){ return S[index]; } } return null; } }3. Student score entry and student score list
package score; import java.util.Scanner; public class ScoreZip2 { public static void main(String[] arr) { Scanner Sc = new Scanner(System.in); ScoreZip Sr = new ScoreZip(); for (int i = 0; i < 5; i++) { //The student score table with length five is defined here System.out.println("Enter student name:"); String name = Sc.next(); if (name.equals("n")) { break; } System.out.println("English score:"); double English = Sc.nextDouble(); System.out.println("Mathematical score:"); double Math = Sc.nextDouble(); System.out.println("Physical score:"); double Physical = Sc.nextDouble(); System.out.println("Chemical score:"); double Chemical = Sc.nextDouble(); System.out.println("Biosity score:"); double Biology = Sc.nextDouble(); Score s = new Score(name, English,Math,Physical,Chemical,Biology); Sr.setData(s, i); } System.out.println("================================================================================================================================================================================================================================================================================================================================================================================================================================================================== System.out.println("Name/t/tEnglish Score/t/tMathematics Score/t/t Physics Score/t/tChemical Score/t/t Biology Score"); Score[] b = Sr.getData(); for (Score S : b) { if (S == null) { break; } System.out.println(S.name + "/t/t" + S.EnglishGrade+"/t/t"+S.MathGrade+"/t/t"+S.phyicalGrade+"/t/t"+S.chemicalGrade+"/t/t"+S.biologicalGrade); } System.out.println("Do you find student grades? Yes Y No N"); String flag = Sc.next(); if(flag.equals("Y")){ System.out.println("Enter the student name to be searched:"); String name = Sc.next(); Score S = Sr.SerchData(name); if (S == null) { System.out.println("Sorry, there is no student name"); } else { double mg = S.MathGrade; double eg = S.EnglishGrade; double pg = S.phyicalGrade; double cg= S.chemicalGrade; double bg = S.biologicalGrade; double submit = mg+eg+pg+cg+bg; System.out.println("The student to be searched is:" + name + "/n Mathematics score is:" + mg + "/n English score is:" + eg+ "/n Physics score is:" + pg+ "/n Chemistry score is:" + cg + "/n Biology score is:" + bg+ "/n Total score is:" + submit); } } } }Results:
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.