Home > Back-end >  What is wrong with you please have a look at the teacher, I do this
What is wrong with you please have a look at the teacher, I do this

Time:10-12

Statistics 100-80, 40-60,59-33-0 6 stages, the number of
Trouble to help teachers to look at me to write? Is there anything that's good, some people say that I write this strange
In
 
Public class Random_05 {
Public static void main (String [] args) {
ArrayList Array1=getScoreList ();
ArrayList Array2=countScore (Array1);
System. The out. Println ("=====================");
PrintConut (Array2);
}
Public static ArrayList GetScoreList () {
ArrayList Array=new ArrayList<> (a);
Random random=new Random();
for (int i=0; I & lt; 50; I++) {
Int num1=random. NextInt (100);
System. The out. Println (num1);
Array. The add (num1);/////////////////////////
}
return array;
}
Public static ArrayList CountScore (ArrayList Array) {
ArrayList Array2=new ArrayList<> (a);//statistics the number of each band
Int a=0, b=0, c=0, d=0;
for (int i=0; I & lt; Array. The size (); I++) {
Int num2=array. Get (I);
If (num2 & lt;=100 & amp; & Num2 & gt; {
=80)+;
} else if (num2 & lt;=79 & amp; & Num2 & gt;=60) {
b++;
} else if (num2 & lt;=59 & amp; & Num2 & gt; 40)={
C + +;
} else if (num2 & lt;=39 & amp; & Num2 & gt;=0) {
D++;
}
}
Array2. Add (a);
Array2. Add (b);
Array2. Add (c);
Array2. Add (d);
Return array2;
}
Public static void printConut (ArrayList Array2) {
for (int i=0; I & lt; Array2. The size (); I++) {
System. The out. Println (array2. Get (I));
}
}
}

CodePudding user response:

If purely in order to meet the topic request, from the code it's nothing serious, just score will not be 100, random. NextInt (100); To the random. NextInt (101);

CodePudding user response:

reference 1st floor qybao response:
if purely in order to meet the topic request, from the code it's nothing serious, just score will not be 100, random. NextInt (100); To the random. NextInt (101);

Well I think should have no problem in 100

CodePudding user response:

Not to say that your code problem, it is said you random scores no 100
The random nextInt (100); Good return value, 0 to 99, not including 100
  • Related