여기서 코드이다누군가 내 Java 코드를 해결할 수 있습니까? 나는 두 번째 이름에 대한 입력을 할 수 없다. 내가해야 할 일은 무엇인가?
import java.util.Scanner;
public class Array2
{
static Scanner input = new Scanner (System.in);
public static void main (String [] args)
{
String [] studentNames = new String [5];
student_Names (studentNames);
}
public static void student_Names (String [] studentNames)
{
for (int x = 0; x < studentNames.length; x++)
{
System.out.printf("\nStudent %d name : ", x+1);
studentNames[x] = input.nextLine();
student_Scores();
}
}
public static void student_Scores()
{
double [] studentScores = new double [4];
int x;
for (x = 0; x < studentScores.length; x++)
{
System.out.printf("\nEnter marks for test %d: ",x+1);
studentScores[x] = input.nextDouble();
}
average_Scores(studentScores);
}
public static void average_Scores(double [] a)
{
int i;
double sum, average;
for (i = 0, sum = 0; i < a.length; i++)
{
System.out.printf("Marks Test %d : %.2f\n", i+1, a[i]);
}
for (i = 0, sum = 0; i < a.length; i++)
{
sum = sum + a[i];
}
average = sum/a.length;
student_Grades (average);
System.out.printf("\nAverage Score : %.2f", average);
}
public static void student_Grades (double b)
{
String c = "";
if (b > 0 && b < 60)
c = "F";
if (b >= 60 && b < 70)
c = "D";
if (b >= 70 && b < 80)
c = "C";
if (b >= 80 && b < 90)
c = "B";
if (b >= 90 && b <= 100)
c = "A";
System.out.printf("\nGrade : %s", c);
}
}
그리고이 수행 될 때의 출력이다
Student 1 name : sss
Enter marks for test 1: 12
Enter marks for test 2: 23
Enter marks for test 3: 34
Enter marks for test 4: 45
Marks Test 1 : 12.00
Marks Test 2 : 23.00
Marks Test 3 : 34.00
Marks Test 4 : 45.00
Grade : F
Average Score : 28.50
Student 2 name :
Enter marks for test 1:
보고있는 오류의 관점에서이 질문을 다시 시도하십시오. –
그의 프로그램은 기본적으로 5 명의 학생 이름과 4 개의 시험 성적 정보를 요구합니다. 그가 가지고있는 문제는 프로그램이 2 학년, 3 학년, 4 학년 및 5 학년 학생의 이름 만 묻는 것이 아니라 자신의 점수 만 묻는 것입니다. –