Novice programmer trying to make a Java restaurant Menu -


i'm trying make menu homework assignment computer science course. thought had down, keep getting errors can't seem fix. can use java 1.4.2, can't use scanner. here code:

updated code

    import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; import java.util.arraylist;  public class javaburger {     static arraylist menuitems = new arraylist();     public static void main(string[] args)     {         inputstreamreader inp = null;         bufferedreader input = null;         int noption  = 0;     double price = 0;     double amount;     double amount1 = 0;     double amount2 = 0;     double amount3 = 0;     double amount4 = 0;     double amount5 = 0;     double amount6 = 0;     double amount7 = 0;     double amount8 = 0;     double amount9 = 0;     double amount10 = 0;     amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amount6 + amount7 + amount8 + amount9 + amount10);         try         {             inp = new inputstreamreader(system.in);             input = new bufferedreader(inp);             while(true)             {         system.out.println("choose menu option");                 system.out.println("1. burger - 13.49");                 system.out.println("2. pasta - 16.79");                 system.out.println("3. salad - 13.49");                 system.out.println("4. salmon - 18.99");                 system.out.println("5. chicken - 16.99");                 system.out.println("6. nachos - 13.99");         system.out.println("7. soup - 6.99");         system.out.println("8. fajitas - 18.49");         system.out.println("9. ribs - 23.99");         system.out.println("10. calamari-9.99");                 system.out.println("\nchoose option(1-10) >> ");         system.out.println("subtotal: $" + amount);         system.out.println("total: $" + (amount * 1.13));                 noption = integer.parseint(input.readline());                  switch(noption)                 {                     case 1:                         burger(input);                         break;             case 2:                         pasta(input);                         break;             case 3:                         salad(input);                         break;             case 4:                         salmon(input);                         break;             case 5:                         chicken(input);                         break;                     case 6:                         nachos(input);                         break;                     case 7:                         soup(input);                         break;                     case 8:                         fajitas(input);                         break;                     case 9:                         ribs(input);                         break;                     case 10:                         calamari(input);                         break;                  }             }         }         catch(exception exp)         {         }     }      public static void burger(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many burgers like? ");         int = integer.parseint(input.readline());         int aa = a.nextint();         double aaa = math.pow(1 + a, aa);             amount1 = (aaa * 13.49);                   break;         }     }       public static void pasta(bufferedreader input) throws ioexception     {         while(true)         {              system.out.println("how many orders of pasta like? ");         int b = integer.parseint(input.readline());         int bb = b.nextint();         double bbb = math.pow(1 + b, bb);             amount2 = (bbb * 16.79);                   break;         }     } public static void salad(bufferedreader input) throws ioexception     {         while(true)         {              system.out.println("how many salads like? ");         int c = integer.parseint(input.readline());         int cc = c.nextint();         double ccc = math.pow(1 + c, cc);             amount3 = (ccc * 13.49);                   break;         }     } public static void salmon(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many orders of salmon like? ");         int d = integer.parseint(input.readline());         int dd = d.nextint();         double ddd = math.pow(1 + d, dd);             amount4 = (ddd * 18.99);                   break;         }     } public static void chicken(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many orders of chicken like? ");         int e = integer.parseint(input.readline());         int ee = e.nextint();         double eee = math.pow(1 + e, ee);             amount5 = (eee * 16.99);                   break;         }     } public static void nachos(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many orders of nachos like? ");         int f = integer.parseint(input.readline());         int ff = f.nextint();         double fff = math.pow(1 + f, ff);             amount6 = (fff * 13.99);                   break;         }     } public static void soup(bufferedreader input) throws ioexception     {         while(true)         {              system.out.println("how many orders of soup like? ");         int g = integer.parseint(input.readline());         int gg = g.nextint();         double ggg = math.pow(1 + g, gg);             amount7 = (ggg * 6.99);                   break;         }     } public static void fajitas(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many orders of 2 fajitas like? ");         int h = integer.parseint(input.readline());         int hh = h.nextint();         double hhh = math.pow(1 + h, hh);             amount8 = (hhh * 18.49);                   break;         }     } public static void ribs(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many racks of ribs like? ");         int = integer.parseint(input.readline());         int ii = i.nextint();         double iii = math.pow(1 + i, ii);             amount9 = (iii * 23.99);                   break;         }     } public static void calamari(bufferedreader input) throws ioexception     {          while(true)         {              system.out.println("how many orders of calamari like? ");         int j = integer.parseint(input.readline());         int jj = j.nextint();         double jjj = math.pow(1 + j, jj);             amount10 = (jjj * 9.99);                   break;         }     }     } 

updated errors:

c:\java\bin>javac javaburger.java javaburger.java:98: error: int cannot dereferenced             int aa = a.nextint();                       ^ javaburger.java:100: error: cannot find symbol             amount1 = (aaa * 13.49);             ^   symbol:   variable amount1   location: class javaburger javaburger.java:114: error: int cannot dereferenced             int bb = b.nextint();                       ^ javaburger.java:116: error: cannot find symbol             amount2 = (bbb * 16.79);             ^   symbol:   variable amount2   location: class javaburger javaburger.java:128: error: int cannot dereferenced             int cc = c.nextint();                       ^ javaburger.java:130: error: cannot find symbol             amount3 = (ccc * 13.49);             ^   symbol:   variable amount3   location: class javaburger javaburger.java:143: error: int cannot dereferenced             int dd = d.nextint();                       ^ javaburger.java:145: error: cannot find symbol             amount4 = (ddd * 18.99);             ^   symbol:   variable amount4   location: class javaburger javaburger.java:158: error: int cannot dereferenced             int ee = e.nextint();                       ^ javaburger.java:160: error: cannot find symbol             amount5 = (eee * 16.99);             ^   symbol:   variable amount5   location: class javaburger javaburger.java:173: error: int cannot dereferenced             int ff = f.nextint();                       ^ javaburger.java:175: error: cannot find symbol             amount6 = (fff * 13.99);             ^   symbol:   variable amount6   location: class javaburger javaburger.java:187: error: int cannot dereferenced             int gg = g.nextint();                       ^ javaburger.java:189: error: cannot find symbol             amount7 = (ggg * 6.99);             ^   symbol:   variable amount7   location: class javaburger javaburger.java:202: error: int cannot dereferenced             int hh = h.nextint();                       ^ javaburger.java:204: error: cannot find symbol             amount8 = (hhh * 18.49);             ^   symbol:   variable amount8   location: class javaburger javaburger.java:217: error: int cannot dereferenced             int ii = i.nextint();                       ^ javaburger.java:219: error: cannot find symbol             amount9 = (iii * 23.99);             ^   symbol:   variable amount9   location: class javaburger javaburger.java:232: error: int cannot dereferenced             int jj = j.nextint();                       ^ javaburger.java:234: error: cannot find symbol             amount10 = (jjj * 9.99);             ^   symbol:   variable amount10   location: class javaburger 20 errors 

errors:

you using null variables:

double amount; double amount1; 

none of these initialized value. null. can inline definition , give them proper values.

double amount = 0, amount1 = 2, amount3 = 5;//etc 

you defining amount twice:

double amount;  double amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amoun t6 + amount7 + amount8 + amount9 + amount10); 

remove double second one:

amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amoun t6 + amount7 + amount8 + amount9 + amount10); 

next, need cast string double.

(input.readline() * 18.49); // should double.parsedouble(input.readline()) * 18.49; 

the readline() method not return numeric value.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -