forked from Programming-Club-IAU/Level-1.4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask4.java
More file actions
102 lines (62 loc) · 2.53 KB
/
Task4.java
File metadata and controls
102 lines (62 loc) · 2.53 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
import java.util.Scanner;
class Student {
String name;
int math;
int phys;
int chem;
int prog;
double gpa;
String excuse;
public Student(String name, int math, int phys, int chem, int prog, double gpa, String excuse) {
this.name = name;
this.math = math;
this.phys = phys;
this.chem = chem;
this.prog = prog;
this.gpa = gpa;
this.excuse = excuse;
}
public boolean success(){
return math >= 44 && phys >= 42 && chem >= 40 &&
prog>= 47 && gpa >= 3.5;
}
public void HospitalAttend(){
if (this.excuse.toLowerCase().contains("hospital")) {
this.math += 1;
this.phys += 1;
this.chem += 1;
this.prog += 1;
}
}
}
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter student's name:");
String name = scanner.nextLine();
System.out.println("Enter attendance for Math:");
int math = scanner.nextInt();
System.out.println("Enter attendance for Physics:");
int phys = scanner.nextInt();
System.out.println("Enter attendance for Chemistry:");
int chem = scanner.nextInt();
System.out.println("Enter attendance for Programming:");
int prog = scanner.nextInt();
System.out.println("Enter GPA:");
double gpa = scanner.nextDouble();
scanner.nextLine();
System.out.println("Enter any excuse message:");
String excuse = scanner.nextLine();
System.out.println("Student information :");
Student student = new Student(name, math, phys, chem, prog, gpa, excuse);
student.HospitalAttend();
System.out.println("Student Name: " + student.name);
System.out.println("Math Attendance: " + student.math);
System.out.println("Physics Attendance: " + student.phys);
System.out.println("Chemistry Attendance: " + student.chem);
System.out.println("Programming Attendance: " + student.prog);
System.out.println("GPA: " + gpa);
String status = student.success() ? "Successful" : "Failure";
System.out.println("Success Status: " + status);
}
}