-
Notifications
You must be signed in to change notification settings - Fork 0
/
feb_PA.java
112 lines (108 loc) · 2.08 KB
/
feb_PA.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Player[] player=new Player[4];
for(int i=0;i<4;i++)
{
int id=sc.nextInt();sc.nextLine();
String name=sc.nextLine();
int exp=sc.nextInt();
int matchesPlayed=sc.nextInt();
int runsScored=sc.nextInt();
player[i]=new Player(id,name,exp,matchesPlayed,runsScored);
}
int target=sc.nextInt();
Player[] player2=averagep(player,target);
for(int i=0;i<player2.length;i++)
{
int x=player2[i].getRunsScored();
int y=player2[i].getMatchesPlayed();
int k=x/y;
if(k>=80 && k<=100)
{
System.out.println("Grade A");
}
else if(k>=50 && k<=79)
{
System.out.println("Grade B");
}
else
{
System.out.println("Grade C");
}
}
}
public static Player [] averagep(Player [] player,int target)
{
Player[] player1=new Player[0];
for(int i=0;i<4;i++)
{
if(player[i].getMatchesPlayed()>=target)
{
player1=Arrays.copyOf(player1,player1.length+1);
player1[player1.length-1]=player[i];
}
}
return player1;
}
}
class Player{
private int id;
private String name;
private int exp;
private int matchesPlayed;
private int runsScored;
public Player(int id,String name,int exp,int matchesPlayed,int runsScored){
this.id=id;
this.name=name;
this.exp=exp;
this.matchesPlayed=matchesPlayed;
this.runsScored=runsScored;
}
//1
public int getId()
{
return id;
}
public void setId(int id)
{
this.id=id;
}
//2
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
//3
public int getExp()
{
return exp;
}
public void setExp(int exp)
{
this.exp=exp;
}
//4
public int getMatchesPlayed()
{
return matchesPlayed;
}
public void setMatchesPlayed(int matchesPlayed)
{
this.matchesPlayed=matchesPlayed;
}
//5
public int getRunsScored()
{
return runsScored;
}
public void setRunsScored(int runsScored)
{
this.runsScored=runsScored;
}
}