我收到错误:编译时找不到符号

时间:2014-01-05 20:09:37

标签: java if-statement compiler-errors

我正在尝试使用IF语句进行计算和汇总,代码如下。错误出现在行上:if(partterms< 6)

   // Setup Array List for Course CU
        ArrayList<Double> coursecu = new ArrayList<Double>();
  // Read inputs for Course Units and Sum the Value
        System.out.println("Please enter Individual Course CU values, Q to quit:");
        Scanner in2 = new Scanner(System.in);
        while (in.hasNextDouble())
        {
            coursecu.add(in.nextDouble());
        } 
        double sum = 0;
        for(int i = 0; i < coursecu.size(); i++)
        {
            sum = sum + coursecu.get(i);
        }
        System.out.println();
        System.out.println("Total Credit Units Required for Graduation");
        System.out.println(sum);
  // Calculate the Number of Terms to Completion
       {
          double fullterm = sum / planned_units; // Sets Whole Terms 
          double partterm = sum % planned_units; // Sets Partial Terms
        }
        if (partterm < 6)
        {
            number_terms = fullterms++;
        }
        else
        {
            number_terms = fullterms;
        }

1 个答案:

答案 0 :(得分:5)

{ ← 
    double fullterm = sum / planned_units; // Sets Whole Terms 
    double partterm = sum % planned_units; // Sets Partial Terms
} ←

删除{},变量将在这个奇怪的块之外知道。