-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkspass.java
More file actions
40 lines (36 loc) · 1.12 KB
/
Copy pathMarkspass.java
File metadata and controls
40 lines (36 loc) · 1.12 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
/*Qus 8:
Given the marks of a student in three subjects, determine if the student has passed or failed. The student passes if they score at least 40 in each subject and the average score is 50 or more.
Input:
Three space-separated integers representing the marks in three subjects.
Output:
Print "Pass" if the student passes, otherwise print "Fail".
Example:
Input:
45 55 60
Output:
Pass
*/
import java.util.Scanner;
public class Markspass
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read the marks for the three subjects
int mark1 = scanner.nextInt();
int mark2 = scanner.nextInt();
int mark3 = scanner.nextInt();
// Check if the student passes
if (mark1 >= 40 && mark2 >= 40 && mark3 >= 40) {
int average = (mark1 + mark2 + mark3) / 3;
if (average >= 50) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}
} else {
System.out.println("Fail");
}
scanner.close();
}
}
//TIMECPMLECITY=O(1)