-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.java
89 lines (48 loc) · 1.06 KB
/
student.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*Write a program to accept 10 students marks in an array, arrange it in ascending order, convert into the following grades and print marks and grades in tabular form.
Between 40 and 50 PASS
Between 51 and 75 MERIT
and above DISTINCTION*/
import java.util.Scanner;
public class student
{
public static void main(String args[])
{
int marks[]= new int[10];
int i,j;
int temp;
String t;
String[] grade= new String[10];
Scanner scanner = new Scanner(System.in);
System.out.print("Enter marks of 10 students:\n");
for(i=0;i<10;i++)
{
marks[i]=scanner.nextInt();
if(marks[i]<40)
grade[i]="Fail";
else if(marks[i]>=40 && marks[i]<=50)
grade[i]="Pass";
else if(marks[i]>=51 && marks[i]<=75)
grade[i]="Merit";
else
grade[i]="Distinction";
}
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++){
if(marks[i]>marks[j])
{temp=marks[i];
t=grade[i];
marks[i]=marks[j];
grade[i]=grade[j];
marks[j]=temp;
grade[j]=t;
}
}
}
System.out.println("\nMarks\tGrade");
for(j=0;j<10;j++)
{
System.out.println(marks[j]+"\t"+grade[j]);
}
}
}