搞清楚我错过的地方}

时间:2012-11-08 02:45:37

标签: java

编译时,我收到此错误:解析时到达文件末尾} ^ 我知道我错过了一个},我最后添加了一个,但仍然得到了同样的编译错误。我的眼睛越来越看着所有} ......任何有一双清晰眼睛的人都可以指出明显的?

解决了...删除代码

3 个答案:

答案 0 :(得分:2)

此代码需要格式化,具有更好的一致性。使用IDE,您可以自己找到解决此类问题的方法。

答案 1 :(得分:0)

没有}来结束swtich

default:
          break;
}

                  c++;

     System.out.print( "\n\t\t\tEnter Another Pledge? (Y/N)?\n\t\t\t" );
     a = Keyboard.nextLine();

答案 2 :(得分:0)

import java.util.Scanner;
import java.text.*;

public class test2
{
  public static void main(String[] args)
  {
      final int Max = 50;
      int c = 0;
      int s = 0;
      int number =0;
      String a;
      char choice, summary;
      Student [] jogathon = new Student[Max];
      Scanner Keyboard = new Scanner(System.in);

        for (int i=0; i< Max; i++) {
        jogathon[i].laps = 0;
        jogathon[i].amount = 0;
        jogathon[i].totals = 0;

        } // make it more visible to relieve yoursel of this problem

      do
      { // next time put tabs after here
      Student.opening();

      System.out.print( "\n\t\tIs this a Donation? (y/n)?\n\t\t" );
          a = Keyboard.nextLine();
          choice = a.charAt(0);

            switch(a)
            { // what an ugly way to format a switch statement...

            case 'n':
          case 'N':
              jogathon[c].getdata();
              s = jogathon[c].number;
              if (s >= 1 && s <= 7)
              {
                  jogathon[c].gettotals();
                  jogathon[c].toString();
                  jogathon[c].showTotals();

              }

              break;

          case 'y':
          case 'Y':
             jogathon[c].number = 0;
             jogathon[c].gettotals();
             jogathon[c].toString();
             jogathon[c].showTotals();

              break;

          default:
          break;
     } // look you forgot the } here at the end of the switch statement
                  c++;
     System.out.print( "\n\t\t\tEnter Another Pledge? (Y/N)?\n\t\t\t" );
     a = Keyboard.nextLine();
     choice = a.charAt(0);
     choice = Character.toUpperCase(choice);
      // this one below goes to the end of the "do{"
     } while (((a == 'Y') || (a == 'y')) && (c > Max));


       for (int i=0; i< c; i++) {
             System.out.println(i + "\t" + jogathon[i].name + "\t" + >money.format(jogathon[i].pledge));
   }

       System.out.println( "===============================\n");
       for (int i=0; i< 7; i++) {
           System.out.println(jogathon[c].names[i] + "\t" + >  >money.format(jogathon[c].totals[i]));
       }
// missing your final }'s here I think maybe you just omitted the rest