2016-03-23 10 views
1

この時点で何が間違っているのかよくわからない。同じ2つのエラーを受け取り続ける:不正な構文解析エラー

CoffeeBot.java:79:表現

}

CoffeeBot.java:82の違法開始:私は、同じ2つのエラーを取得してきたファイルの終わりに達しを

を解析中

} //パブリッククラス

2エラー

誰かが私に感謝しますか?

import java.util.Scanner ; 

public class CoffeeBot { 

    public static void main(String[] args) { 

     int n1 = Integer.parseInt(args[0]); 
     int n2 = Integer.parseInt(args[1]); 

     for (int i = 0;i<args.length;i++) // REMEMBER TO PUT IN ARGS LENGTH 

     if (!(n1 > 0) && !(n2 > 0)) { // This is for both negative inputs n1 and n2 

     System.out.println("Negative supply chain. System terminating."); 

     return; 

     } 

     if (n1 < 0) { // This is for negative input n1 

     System.out.println("Negative supply of coffee cups. System terminating."); 

      return; 

     } 

     if (n2 < 0) { // This is for negative input n2 

     System.out.println("Negative supply of coffee shots. System terminating."); 

      return; 

     } 

     else {// If inputs comply with rules then proceed to here 

     System.out.println("Hello, what's your name?"); 

     String name; 

     Scanner keyboard = new Scanner(System.in); 

      name = keyboard.next(); 

     System.out.println("Would you like to order some coffee, " + name + "? (y/n)"); 

     String yesno; 

      yesno = keyboard.next(); 

      if (yesno.equalsIgnoreCase("y")) { 

       System.out.println("Great! Let's get started."); 

       System.out.println(" "); 

       System.out.println("Order selection"); 

       System.out.println("---------------"); 

       System.out.println(" "); 

      } 

      if (yesno.equalsIgnoreCase("n")) { 

       System.out.println("Come back next time, " + name +"."); 

       return; 
      } 

      else { 

       System.out.println("Invalid response. Try again."); 

       while (yesno.toIgnoreCase("n")) 
       while (yesno.toIgnoreCase("y")) 
      } 

     }//else 

    } //main args 

} //public class 
+0

'while(yesno.toIgnoreCase(" n "))'および 'while(yesno.toIgnoreCase(" y "))'は正しくフォーマットされていません – apicellaj

+0

関連はありませんが、 –

答えて

0

yesnoタイプStringです。

while (yesno.toIgnoreCase("n")) 
while (yesno.toIgnoreCase("y")) 

は、私はあなたがループがいっそ{}すべての時間を使用しながら、第二後;を置く.also equalsIgnoreCase()を意味推測し、何toIgnoreCase()方法はありません。

+0

これを行うと、コードがコンパイルされる可能性がありますが、その2つの好きなものはまだ非常に間違っています。 – Andreas

関連する問題