预计支架....不知道在哪里

时间:2013-12-03 23:12:38

标签: java debugging

所以我正在进行关于模块化编程的任务,这里我得到一个支架预期错误。这是代码:

import java.util.*;

public class stlab09
{       

public static void main (String args[])                             
{   
    System.out.println("\nLAB09 90 POINT VERSION\n\n");
    enterData();
    computeGPA();
    displayData();
}

static String lGrade1;
static String lGrade2;
static String lGrade3;
static String lGrade4;
static int cHours1; 
static int cHours2;
static int cHours3;
static int cHours4;
static String dummy;
public static double gpa;

public static void enterData()
{       
    Scanner in = new Scanner(System.in);    
    System.out.print("Enter course 1 Grade  ===>>  ");
    lGrade1 = in.nextLine();
    System.out.print("enter course 1 Hours  ===>>  ");
    cHours1 = in.nextInt(); dummy = in.nextLine();
    System.out.print("Enter course 2 Grade  ===>>  ");
    lGrade2 = in.nextLine(); 
    System.out.print("enter course 2 Hours  ===>>  ");
    cHours2 = in.nextInt(); dummy = in.nextLine();
    System.out.print("Enter course 3 Grade  ===>>  ");
    lGrade3 = in.nextLine(); 
    System.out.print("enter course 3 Hours  ===>>  ");
    cHours3 = in.nextInt(); dummy = in.nextLine();
    System.out.print("Enter course 4 Grade  ===>>  ");
    lGrade4 = in.nextLine(); 
    System.out.print("enter course 4 Hours  ===>>  ");
    cHours4 = in.nextInt(); dummy = in.nextLine();
}

public static void computeGPA()
{
    Grades.gradeValue();
    Grades.courseValue();
    Grades.getGPA();
}

public static void displayData()
{   
    System.out.println();
    System.out.println("Course1 Grade: " + lGrade1 +  "  Course1 Credit Hours: " + cHours1);
    System.out.println("Course2 Grade: " + lGrade2 +  "  Course2 Credit Hours: " + cHours2);
    System.out.println("Course3 Grade: " + lGrade3 +  "  Course3 Credit Hours: " + cHours3);
    System.out.println("Course4 Grade: " + lGrade4 +  "  Course4 Credit Hours: " + cHours4);
    System.out.println();
    System.out.println("Current GPA: " + gpa);
}
}

public class Grades() ***<<<<<<<<<<<<<<<<<< bracket expected here***
{
public static void gradeValue()
{
    int value = 0;

    char lg1 = lGrade1.charAt(0);
    switch(lg1)
        {
            case 'A':  value = 4;  break;
            case 'B':  value = 3;  break;
            case 'C':  value = 2;  break;
            case 'D':  value = 1;  break;
            case 'F':  value = 0;  break;
        }

    int gVal1 = value;

    char lg2 = lGrade2.charAt(0);
    switch(lg2)
        {
            case 'A':  value = 4;  break;
            case 'B':  value = 3;  break;
            case 'C':  value = 2;  break;
            case 'D':  value = 1;  break;
            case 'F':  value = 0;  break;
        }

    int gVal2 = value;

    char lg3 = lGrade3.charAt(0);
    switch(lg3)
        {
            case 'A':  value = 4;  break;
            case 'B':  value = 3;  break;
            case 'C':  value = 2;  break;
            case 'D':  value = 1;  break;
            case 'F':  value = 0;  break;
        }

    int gVal3 = value;

    char lg4 = lGrade4.charAt(0);
    switch(lg4)
        {
            case 'A':  value = 4;  break;
            case 'B':  value = 3;  break;
            case 'C':  value = 2;  break;
            case 'D':  value = 1;  break;
            case 'F':  value = 0;  break;
        }
    int gVal4 = value; 
}

public static void courseValue()
{ 
    int cVal1 = gVal1 * cHours1;
    int cVal2 = gVal2 * cHours2;
    int cVal3 = gVal3 * cHours3;
    int cVal4 = gVal4 * cHours4;
}

public static void getGPA()
{
    double totalValue = cVal1 + cVal2 + cVal3 + cVal4;
    double totalHours = cHours1 + cHours2 + cHours3 + cHours4;
    double gpa = totalValue / totalHours;
}
}

所以是的,我需要一些帮助来解决这个问题,因为我有点疯狂。预期的程序应该使用字母等级和课程时间的键盘输入来计算GPA和成绩。分配是为了获得结果,但主要方法必须保持原样,几乎每种方法都提供给我,我只需要组织它们。

1 个答案:

答案 0 :(得分:1)

你已经将内部类Grades声明为一个方法(你在其末尾添加了()),看看如何声明类stlab09,没有'任何()