forked from Programming-Club-IAU/Level-1.4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
90 lines (78 loc) · 2.38 KB
/
Student.java
File metadata and controls
90 lines (78 loc) · 2.38 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package github;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
/**
*
* @author SOADAD
*/
public class Student {
private String name;
private int mathAttendance;
private int physicsAttendance;
private int chemistryAttendance;
private int programmingAttendance;
private double grade;
private String result;
public Student(String name) {
this.name = name;
this.mathAttendance = 0;
this.physicsAttendance = 0;
this.chemistryAttendance = 0;
this.programmingAttendance = 0;
this.grade = 0.0;
this.result = "";
}
public void inputAttendance(Scanner scanner) {
System.out.println("Enter the attendance for each subject:");
System.out.print("Math: ");
mathAttendance = scanner.nextInt();
System.out.print("Physics: ");
physicsAttendance = scanner.nextInt();
System.out.print("Chemistry: ");
chemistryAttendance = scanner.nextInt();
System.out.print("Programming: ");
programmingAttendance = scanner.nextInt();
scanner.nextLine(); // Consume newline character
}
public void inputGrade(Scanner scanner) {
System.out.print("Enter grade for the semester (out of 5): ");
grade = scanner.nextDouble();
if (isSuccess()) {
result = "Success";
} else {
result = "Failure";
}
}
public boolean isSuccess() {
return mathAttendance >= 44 && physicsAttendance >= 42 &&
chemistryAttendance >= 40 && programmingAttendance >= 47 &&
grade >= 3.5;
}
public int getMathAttendance() {
return mathAttendance;
}
public int getPhysicsAttendance() {
return physicsAttendance;
}
public int getChemistryAttendance() {
return chemistryAttendance;
}
public int getProgrammingAttendance() {
return programmingAttendance;
}
public double getGrade() {
return grade;
}
public String getResult() {
return result;
}
}