-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP19.java
More file actions
65 lines (59 loc) · 1.02 KB
/
P19.java
File metadata and controls
65 lines (59 loc) · 1.02 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
60
61
62
63
64
65
import java.util.*;
class Student{
String n;
int rn;
int a;
int e[]= new int[100];
String w[]=new String[100];
int q[]= new int[100];
Student()
{
String name=n;
int roll=rn;
int age=a;
}
void set(int d)
{
Scanner sc=new Scanner(System.in);
String s1=sc.next();
int r1=sc.nextInt();
int a1=sc.nextInt();
n=s1;
rn=r1;
a=a1;
e[d]=rn;
w[d]=n;
q[d]=a;
}
void get()
{
for(int i=0;i<e.length;i++)
for(int j=0;j<e.length;j++ )
{
if(e[j]>e[j+1])
{
int k=e[j];String k1=w[j];int k2=q[j];
e[j]=e[j+1];w[j]=w[j+1];q[j]=q[j+1];
e[j+1]=e[j];w[j+1]=w[j];q[j+1]=q[j];
}
}
for(int y=0;y<e.length;y++)
System.out.println(w[y]+" "+e[y]+" "+q[y]);
}
}
public class P19 {
public static void main(String[] args) {
Student s=new Student();
Scanner sc=new Scanner(System.in);
String c=sc.next();
int r=0;
int d=0;
while(c!="n")
{
s.set(d);
c=sc.next();
d++;
}
s.get();
}
}