-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentGrade.java
More file actions
25 lines (19 loc) · 874 Bytes
/
StudentGrade.java
File metadata and controls
25 lines (19 loc) · 874 Bytes
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
import java.util.Scanner;
public class StudentGrade {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Student Name: ");
String name = sc.nextLine();
System.out.print("Enter Marks (out of 100) for 3 subjects: ");
int m1 = sc.nextInt(), m2 = sc.nextInt(), m3 = sc.nextInt();
int total = m1 + m2 + m3;
double percentage = total / 3.0;
char grade = (percentage >= 90) ? 'A' : (percentage >= 80) ? 'B' :
(percentage >= 70) ? 'C' : (percentage >= 60) ? 'D' : 'F';
System.out.println("\nStudent: " + name);
System.out.println("Total Marks: " + total);
System.out.println("Percentage: " + percentage + "%");
System.out.println("Grade: " + grade);
sc.close();
}
}