1+ import java .util .ArrayList ;
2+
3+ class moduleInfo {
4+ public String moduleName ;
5+ public int gradeNum ;
6+ public char gradeLetter ;
7+
8+ public moduleInfo (String mN , long gN , char gL ){
9+ this .moduleName = mN ;
10+ this .gradeNum = Math .toIntExact (gN );
11+ this .gradeLetter = gL ;
12+ }
13+ }
14+
15+ public class student {
16+ public int studentNum ;
17+ public String studentName ;
18+ public String studentSurname ;
19+ public String dateOfBirth ;
20+ public int studentAge ;
21+ public String mobileNum ;
22+ public String studentAddress ;
23+ public String studentGender ;
24+ public ArrayList <moduleInfo > modules = new ArrayList <>();
25+
26+ public student (Long studentnum , String studentname , String studentsurname , String DOB , Long Age , String mobile , String address , String gender ){
27+ this .studentNum = Math .toIntExact (studentnum );
28+ this .studentName = studentname ;
29+ this .studentSurname = studentsurname ;
30+ this .dateOfBirth = DOB ;
31+ this .studentAge = Math .toIntExact (Age );
32+ this .mobileNum = mobile ;
33+ this .studentAddress = address ;
34+ this .studentGender = gender ;
35+ }
36+
37+ public void addModule (moduleInfo module ){
38+ module .gradeLetter = this .calcgradeCHAR (module .gradeNum );
39+ this .modules .add (module );
40+ }
41+ private char calcgradeCHAR (int gradenum ){
42+ if (gradenum >= 90 && gradenum <= 100 )return 'A' ;
43+ else if (gradenum >= 80 && gradenum <= 89 )return 'a' ;
44+ else if (gradenum >= 70 && gradenum <= 79 )return 'B' ;
45+ else if (gradenum >= 60 && gradenum <= 69 )return 'C' ;
46+ else if (gradenum >= 50 && gradenum <= 59 )return 'D' ;
47+ else if (gradenum >= 40 && gradenum <= 49 )return 'E' ;
48+ else if (gradenum >= 30 && gradenum <= 39 )return 'F' ;
49+ else return 'F' ;
50+ }
51+
52+ /*public void displayStudent(){
53+ System.out.println(" STUDENTNUMBER: " + this.studentNum);
54+ System.out.print(" STUDENTNAME: " + this.studentName);
55+ System.out.print(" STUDENTSURNAME: " + this.studentSurname);
56+ System.out.print(" DATEOFBIRTH: " + this.dateOfBirth);
57+ System.out.print(" STUDENTAGE: " + this.studentAge);
58+ System.out.println(" MOBILENUMBER: " + this.mobileNum);
59+ System.out.print(" STUDENTADDRESS: " + this.studentAddress);
60+ System.out.print(" STUDENTGENDER: " + this.studentGender);
61+ System.out.print(" MODULES:");
62+ for(int i = 0; i < this.modules.size(); ++i){
63+ System.out.print(" " + this.modules.get(i).moduleName + " : " + this.modules.get(i).gradeNum + "/" + this.modules.get(i).gradeLetter);
64+ }
65+ System.out.println();
66+ System.out.println();
67+ }*/
68+ }
0 commit comments