java arraylist有问题吗
我需要做的是创建一个数组,存储所有分数,并反向显示数字。救命~~!! 这就是我想到的
//wbin
import java.util.Scanner;
import java.text.DecimalFormat;
public Class ArrayPractice
{
public static void main(String[] args) {
int count = 0;
int total = 0;
final int SENTINEL = 0;
int score;
int sum;
Scanner scan = new Scanner( System.in );
System.out.println( "Enter your score then Press 0 to display your average and total score. " );
System.out.println( "When you are finished, Press 0" );
System.out.print( "Enter the first test score > " );
score = scan.nextInt( );
while ( score != SENTINEL )
{
total = score + total;
count++;
System.out.print( "Enter the next test score > " );
score = scan.nextInt( );
}
if ( count != 0 )
{
DecimalFormat oneDecimalPlace = new DecimalFormat( "##.0" );
System.out.println("\nYour Average is "
+ oneDecimalPlace.format( (double) ( total / count) ) );
System.out.println("Your Total score is " + total);
}
else
System.out.println( "\nNo grades were entered" );
}
}
# 1 楼答案
在循环中添加个人分数:
你可以做另一个循环,反向显示你的成绩:
希望这有帮助