私は Java の初級コースに参加していますが、ユーザー入力からデータを抽出し、それを使用してユーザー入力の量に基づいて一連の成績を作成するのに問題があります。次に、そのデータセットを最高のものから最低のものまで整理し、平均化することを想定しています。これまでの私のコードは次のとおりです
//import Scanner
import java.util.Scanner;
public class Looper {
public static void main(String[] args) {
//introduce integers
int highest = 0;
int lowest = 0;
int count = 0;
int grade = (int) (Math.random() * 100);
int student;
int total = 0;
double average = 0;
//introduce Scanner
Scanner input = new Scanner(System.in);
//printout number of students
System.out.println("Enter number of students");
student = input.nextInt();
//narrow amount of students
if (student <= 10) {
System.out.println("Enter the grades of the students");
}
else if (student >= 11) {
System.out.println("Too many Students");
}
//close off 0
while (student != 0) {
System.out.println("Didn't enter students");
}
grade = input.nextInt();
//connect student and grade
for (grade = 0; grade <= 100; grade++) {
student = grade;
if (grade > 100) {
System.out.println("Must be between 0 and 100")
} if (grade <= highest) {
grade++;
}
}
for (grade = 0; grade >= 0; grade++) {
student = grade;
if (grade < -1) {
System.out.println(" Must be between 0 and 100");
}
else if (grade >= lowest) {
grade++;
}
// form total and average
total = total + grade;
grade++;
{
average = (double) total / grade;
//printout highest, lowest, and average
System.out.println("The highest is" + highest + "\n The lowest is" + lowest + "The average is\n" + average);
}
}
}
}