-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestScore.java
More file actions
59 lines (58 loc) · 1.61 KB
/
TestScore.java
File metadata and controls
59 lines (58 loc) · 1.61 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
// Program: Calculate Total Marks and Grade for Students
// Topic: 2D Arrays and Conditional Statements
// Description: Stores marks of students in multiple subjects using a 2D array.
// Calculates total marks and average for each student, then assigns a grade (A–D) based on the average score.
package Array;
import java.util.*;
/**
*
* @author Samim
*/
public class TestScore
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int ar[][]=new int[2][3];
int total[]=new int[2];
char Grade[]=new char[2];
int avg;
for(int i=0;i<2;i++)
{
total[i]=0;
System.out.println("Subject "+(i+1));
for(int j=0;j<3;j++)
{
System.out.println("Student :"+(j+1));
ar[i][j]=sc.nextInt();
total[i]+=ar[i][j];
}
}
for(int i=0;i<2;i++)
{
avg=total[i]/3;
if(avg<45)
{
Grade[i]='D';
}
else if(avg>=45 && avg<60)
{
Grade[i]='C';
}
else if(avg>=60 && avg<75)
{
Grade[i]='B';
}
else if(avg>=75)
{
Grade[i]='A';
}
}
for(int i=0;i<2;i++)
{
System.out.println("Student "+(i+1));
System.out.println("Total Marks ="+total[i]);
System.out.println("\tGrade ="+Grade[i]);
}
}
}