2016-03-23 24 views
1

Bu noktada yanlış yaptığımdan emin değilim.Aynı iki hatayı almaya devam edin: yasadışı ve ayrıştırma hatası

CoffeeBot.java:79:: İfade

}

CoffeeBot.java:82 yasadışı başlangıç: Ben aynı iki hata alıyorum dosyanın sonuna ulaştı

ayrıştırılırken

} // public class

2 hataları

Birisi beni düzeltiyor?

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

'(yesno.toIgnoreCase (" n "))' ve 'while (yesno.toIgnoreCase (" y "))' yanlış biçimlendirilmiş – apicellaj

+0

İlgili değil, ancak ASAP kodunuzu doğru şekilde nasıl biçimlendireceğinizi öğrenmelisiniz. –

cevap

0

yesno tip String taşımaktadır.

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

i döngü daha iyisi {} her zaman kullanırken sonra 2. ; koymak .also equalsIgnoreCase() ettiğinizi tahmin, hiçbir toIgnoreCase() yöntem yoktur.

+0

Bunu yapmak kodun derlenmesini sağlayabilir, ancak bu iki beğeni hala çok yanlıştır, bu acıtır. – Andreas

İlgili konular