我不知道如何处理错误了



嗨,我还是个新手,我花了一天的时间编写这些代码。它有很多错误,以至于我再也看不懂了。你能帮助解决代码的问题并修改它以使其工作或运行吗?

这里是我的代码

import java.util.Scanner;
import java.io.*;
public class GradeDistribution
{
public static void main(String[] args)
{
print_header();
Scanner kb = new Scanner (System.in);
{
System.out.println("******************************************************");
System.out.println("This program will present the number of grades" ); //INTRODUCTION
System.out.println("you input for grades A-F and turn this information"); //TO
System.out.println("in to a bar graph for ease."); //PROGRAM
System.out.println("******************************************************");
System.out.println(" ");

for(double loopcounter=0; loopcounter<5; loopcounter++)
{
switch(loopcounter)
{

case 0:  "nGrade A: |"; break;
case 1:  "Grade B: |"; break;
case 3:  "Grade C: |"; break;
case 4:  "Grade D: |"; break;
case 5:  "Grade F: |"; break;
}

//loop to output each asterisk
for(double asteriskcounter=0; asteriskcounter<array[loopcounter]/2; 
asteriskcounter++)
System.out.println ('*');
System.out.println("| " << array[loopcounter] << '%');
}
percent=100/14; // 7;
System.out.println(" ");
System.out.println(" TOTAL GRADES ENTERED - ");
char[] line = percent*a/2;//3; Bcent=percent*b/2; Ccent=percent*c/2; Dcent=percent*d/2; 
Ecent=percent*e/2; Fcent=percent*f/2;
} //end;
System.out.println(" 0 10 20 30 40 50 60 70 80 90 100");
System.out.println(" | | | | | | | | | | |");
System.out.println(" **************************************************");
double array[6] = {Acent, Bcent, Ccent, Dcent, Ecent, Fcent}; //stores grades as 
percentage
char[] line = array2[6] = {'A','B','C','D','E','F'}; //stores letters a-f
// loop for each grade
for(double loopcounter=0; loopcounter<6; loopcounter++)
{
System.out.println(" ");
// loop to output each asterisk
for(double asteriskcounter=0; asteriskcounter<array[loopcounter]; asteriskcounter++)
{
System.out.println("*");
}
// prdouble the grade after the asterisks
System.out.prdoubleln( " GRADE "[loopcounter]);

请再帮我一次。因为我的作业真的需要它,而且我已经很难赶上进度了。事先非常感谢您的帮助。

您应该检查括号,因为有些括号丢失了。

你的代码中没有print_header()方法,为它定义一个方法

如果你想在开关情况下得到输出,你应该使用System.out.print()或System.out.println()方法,因为你刚刚在那里写了一些字符串。

在for循环中,你写了"array[loopcounter]",你没有一个名为"array"的数组。

,"percent"变量应该有一个数据类型

在下面的数组中,名称为"array"有一些字符串(它们应该有双引号),但您将此数组定义为char。你应该使用String.

最后一个问题是" system .out. prodoubleln ()"方法。系统。Out没有这个方法。

  • 在循环中使用int变量

快我都检查过了,已经看到这些问题。