-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindStudentsTotalScore.java
More file actions
197 lines (163 loc) · 6.11 KB
/
FindStudentsTotalScore.java
File metadata and controls
197 lines (163 loc) · 6.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import java.util.Scanner;
public class FindStudentsTotalScore{
public static void main(String[] args) throws Exception {
Student student = new Student();
System.out.print("Input your name : ");
Scanner scanner = new Scanner(System.in);
String studentName = scanner.nextLine();
student.setStudentName(studentName);
System.out.print("Input your ID : ");
int studentID = scanner.nextInt();
student.setStudentID(studentID);
System.out.print("Input your English score : ");
double english = scanner.nextDouble();
student.setEnglish(english);
System.out.print("Input your Maths score : ");
double maths = scanner.nextDouble();
student.setMaths(maths);
SOL_Student sol_Student = new SOL_Student();
SOCIE_Student socie_Student = new SOCIE_Student();
boolean isRunning = true;
int department = -1;
while (isRunning) {
System.out.print("\n1 - for SOL\n2 - for SOCIE\nChoose your department : ");
department = scanner.nextInt();
if (department == 1) {
System.out.print("Input your Intro To Economics score : ");
double intro_to_Eco = scanner.nextDouble();
sol_Student.setIntro_to_Eco(intro_to_Eco);
System.out.print("Input your Computer Programming score : ");
double computerProgramming = scanner.nextDouble();
sol_Student.setComputerProgramming(computerProgramming);
sol_Student.setEnglish(student.getEnglish());
sol_Student.setMaths(student.getMaths());
break;
} else if (department == 2) {
System.out.print("Input your OOP1 score : ");
double oop1 = scanner.nextDouble();
socie_Student.setOOP1(oop1);
System.out.print("Input your Intro To IT score : ");
double intro_to_IT = scanner.nextDouble();
socie_Student.setIntro_to_IT(intro_to_IT);
socie_Student.setEnglish(student.getEnglish());
socie_Student.setMaths(student.getMaths());
break;
} else {
System.out.println("Wrong input!");
}
}
System.out.println("\nStudent Name : " + student.getStudentName());
System.out.println("Student ID : " + student.getStudentID());
System.out.println("English Score : " + student.getEnglish());
System.out.println("Maths Score : " + student.getMaths());
if (department == 1) {
System.out.println("Intro To Economics Score : " + sol_Student.getIntro_to_Eco());
System.out.println("Computer Programming Score : " + sol_Student.getComputerProgramming());
System.out.println("Total Score : " + sol_Student.total_Score());
} else if (department == 2) {
System.out.println("OOP1 Score : " + socie_Student.getOOP1());
System.out.println("Intro To IT Score : " + socie_Student.getIntro_to_IT());
System.out.println("Total Score : " + socie_Student.total_Score());
}
scanner.close();
}
}
class Student {
private String studentName;
private int studentID;
private double english;
private double maths;
public Student() {
}
public Student(String studentName, int studentID, double english, double maths) {
this.studentName = studentName;
this.studentID = studentID;
this.english = english;
this.maths = maths;
}
public String getStudentName() {
return this.studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public int getStudentID() {
return this.studentID;
}
public void setStudentID(int studentID) {
this.studentID = studentID;
}
public double getEnglish() {
return this.english;
}
public void setEnglish(double english) {
this.english = english;
}
public double getMaths() {
return maths;
}
public void setMaths(double maths) {
this.maths = maths;
}
public double total_Score() {
return this.english + this.maths;
}
}
class SOL_Student extends Student {
private double intro_to_Eco;
private double computerProgramming;
public SOL_Student() {
intro_to_Eco = 0;
computerProgramming = 0;
}
public SOL_Student(String studentName, int studentID, double english, double maths, double computerProgramming,
double intro_to_Eco) {
super(studentName, studentID, english, maths);
this.intro_to_Eco = intro_to_Eco;
this.computerProgramming = computerProgramming;
}
public double getComputerProgramming() {
return this.computerProgramming;
}
public void setComputerProgramming(double computerProgramming) {
this.computerProgramming = computerProgramming;
}
public double getIntro_to_Eco() {
return this.intro_to_Eco;
}
public void setIntro_to_Eco(double intro_to_Eco) {
this.intro_to_Eco = intro_to_Eco;
}
@Override
public double total_Score() {
return super.total_Score() + this.getIntro_to_Eco() + this.getComputerProgramming();
}
}
class SOCIE_Student extends Student {
private double oop1;
private double intro_to_IT;
public SOCIE_Student() {
}
public SOCIE_Student(String studentName, int studentID, double english, double maths, double oop1,
double intro_to_IT) {
super(studentName, studentID, english, maths);
this.oop1 = oop1;
this.intro_to_IT = intro_to_IT;
}
public double getOOP1() {
return this.oop1;
}
public void setOOP1(double oop1) {
this.oop1 = oop1;
}
public double getIntro_to_IT() {
return this.intro_to_IT;
}
public void setIntro_to_IT(double intro_to_IT) {
this.intro_to_IT = intro_to_IT;
}
@Override
public double total_Score() {
return super.total_Score() + this.getOOP1() + this.getIntro_to_IT();
}
}