CodePudding user response:
Import the Java. Math. BigDecimal;
Import the Java. Util. ArrayList;
Import the Java. Util. List;
import java.util.Scanner;
Public class T {
Public static void main (String [] args) {
ListList=new ArrayList (a);
System. The out. Println (" both please enter the num: ");
Int sum=0;
Scanner scan=new Scanner(System.in);
While (true) {
String STR=scan. The next ();
Try {
Int num=Integer. The valueOf (STR);
If (num==0) {
break;
}
If (num & lt; 0 {
System. Out. Println (" grades input wrong ");
break;
}
List. The add (num);
The sum +=num;
} the catch (Exception e) {
e.printStackTrace();
}
}
For (int num: list) {
System. The out. Print (num + "");
}
System.out.println();
BigDecimal avg=new BigDecimal (sum). Divide (new BigDecimal (list. The size ())). SetScale (2);
If (avg.com pareTo (new BigDecimal (60)) & lt; 0 {
System. The out. Println (" result is unqualified ");
} else {
System. The out. Println (" passed ");
}
}
}
CodePudding user response:
22 is less than 0 why the break,To continue should continue to the next round of cycle