-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask9.java
More file actions
46 lines (35 loc) · 1.54 KB
/
Copy pathTask9.java
File metadata and controls
46 lines (35 loc) · 1.54 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
// Take marks of five subjects and calculate the total, percentage, and grade using if-else.
import java.util.Scanner;
public class Task9 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first Sub Mark :");
int sub1=sc.nextInt();
System.out.println("Enter the Secod Sub Mark :");
int sub2=sc.nextInt();
System.out.println("Enter the Third Sub Mark:");
int sub3=sc.nextInt();
System.out.println("Enter the Forth Sub Mark:");
int sub4=sc.nextInt();
System.out.println("Enter the Mark of Fifth Subject:");
int sub5=sc.nextInt();
int total=sub1+sub2+sub3+sub4+sub5;
double percentage=(total/500.0)*100;
System.out.println("Total marks="+total);
System.out.println("Prcentage="+percentage+"%");
sc.close();
if (percentage >=90){
System.out.println("Congratulations you got an A+");
}else if(percentage >=80 && percentage<89){
System.out.println("Congratulations you got an A)");
}else if (percentage >=70 && percentage <=79){
System.out.println("You have got B+");
}else if (percentage >=60 && percentage <=69){
System.out.println("You have got B");
}else if (percentage >=50 && percentage <=59){
System.out.println("You have passed but work harder next time");
}else{
System.out.println("You have failed in the exam work hard");
}
}
}