Time:10-13
CodePudding user response:
to help you do this, paid?
import java.util.*; The import static Java. Util. Stream. Collectors. *; Public class Solution {Private static String [] levelNames={" below 60 points ", "60-69", "70-79", "80-89", "90-99", "100"}; Private static String averageName="average"; Private static int endFlag=1; Private static Scanner Scanner=new Scanner (System. In); Public static void main (String [] args) {List ScoresList=getScores (); ScoresList. Stream (). Collect (groupingBy (T: : getLevelName, counting ())) The forEach ((k, v) - & gt; System. Out. Println (the String. Format (" % s: % d ", k, v))); Double averageScore=scoresList. Stream (). Collect (summarizingInt (t - & gt; T)). GetAverage (); System. Out. Println (the String. Format (" % s: % 2 f, "averageName, averageScore)); } Public static String getLevelName (Integer score) {Score/=10; Return levelNames [score & lt; 6? 0: score - 5]; } Public static List GetScores () {List ScoreList=new ArrayList<> (a); Int score; While ((score=scanner. NextInt ())!={endFlag) If (score & lt; 0 | | score & gt; 100) {Throw new IllegalArgumentException (" illegal input!" ); } ScoreList. Add (score); } Return scoreList; } }
everyone a great god, small white solving ah
Public static void main (String [] args) {//TODO Auto - generated method stub Scanner sc=new Scanner (System. In); Int a=0, b=0, c=0, d=0, e=0, f=0, sum=0, I; While ((I=sc. NextInt ())!=1) {Sum=sum + I; If (i<60) {a++; } else if (i<{=69)b++; } else if (i<{=79)c++; } else if (i<{=89)d++; } else if (i<{=99)E++; } else {F++; } } System. The out. Println (under "60 minutes" + a + "60-69 people, with an" a + b + "with" 70-79 + c + "with" 80-89 + d + "with" 90-99 + e + "100 points" + e + "person"); System. The out. Println (" average scores for "+ sum/(a + b + c + d + e + f)); }
define a variable as the total number of Define a variable as the total score Define an array of length 5 Define a for loop Input result Is equal to 1 is break Less than 60 array [0] 1 So on The total score plus the time score The total number of add a Finally the block number is the number of each array subscript Average scores for the total score divided by the total number of
Page link:https//www.codepudding.com/Backend/64568.html