Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions Task 1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
boolean HE=false;
int[] attendance = new int[4];
String[] subject = {"Math", "Physics", "Chemistry", "Programming"};
System.out.print("Enter student name: ");
String name = sc.nextLine();
for (int i = 0; i < 4; i++) {
System.out.print("Enter the attendance for " + subject[i] + " : ");
attendance[i] = sc.nextInt();
}
sc.nextLine();
System.out.print("Enter excuse of absence (HE for Hosbital excuse): ");
String excuse = sc.nextLine();
if(excuse=="HE" || excuse =="he" || excuse=="He"){
HE=true;}
else{
for (int i = 0; i < 4; i++){
attendance[i]++;
}
}
String result;
System.out.print("Enter grade for the semester (out of 5): ");
double grade = Double.parseDouble(sc.nextLine());

if(grade > 3.5 && attendance[0] > 43 && attendance[1]> 41 && attendance[2]>39 && attendance[3]>46 ){
result = "Succeed";
}
if(grade > 5 || grade<0){
result =" Sorry!! there is an error **You should enter your grade out of five**";
}
else{
result = "failed";
}
System.out.println("\nStudent information:");
for (int i = 0; i < 4; i++) {
System.out.println(subject[i] + " Attendance: " + attendance[i] + " days");
}
System.out.println("Grade: " + grade);
System.out.println("Result: " + result);
sc.close();
}
}