Home > Back-end >  For Java coding
For Java coding

Time:12-30

Define an integer array called scores, assigns 100 elements of space, program accepts user input from the keyboard grades, when the user input 1 input end (not more than 100 the number of student performance), request to save these achievements into scores array, finally, the output with the score of all grades, the average score, the highest and lowest points,

CodePudding user response:

Not in the list, please be sure to use an array?

CodePudding user response:

 
import java.util.*;

/* *
* @ author zhaojinhui
* @ date 2020/12/29 9:51
* @ apiNote
*/
Public class Score {
Public static void main (String [] args) {
The Integer [] scores=new Integer [100].
Scanner Scanner=new Scanner (System. In);
int i=1;
System. The out. Println (" please enter a number, press 1 end ");
While (I & lt; {
=100)i++;
Int inNum=scanner. NextInt ();
System. The out. Println (" please enter a number, press 1 end ");
If (inNum==1) {
break;
} else {
Scores [I]=inNum;
}
}
List List=new ArrayList<> (a);
Collections. AddAll (list, scores);
List. RemoveAll (Collections. The singleton (null));
List. The forEach (System. Out: : println);
DoubleSummaryStatistics statistics=list. Stream (). MapToDouble (Number: : doubleValue). SummaryStatistics ();
System. The out. Println (" points: "+ statistics. GetMax ());
System. The out. Println (" minimum points: "+ statistics. GetMin ());
System. The out. Println (" average: "+ Math. Round (statistics) getAverage ()));
System. The out. Println (" total points: "+ statistics. GetSum ());
System. The out. Println (" total number: "+ statistics. GetCount ());


}
}

CodePudding user response:

The
reference 1/f, still have a chance to use a float soft reply:
not in the list must use an array?

Have to use an array
  • Related