Im trying to add a new item in an existing list of menu. and the program will keep asking if you would like to add a new item in the menu. until i input a cue that it will stop asking.
ok so I try to do that. so I paste here my code..
if you input a "space" on the prompt "Enter your new menu" the loop will be terminated.
but i have a problem whenever i input an another menu
the arrays was just being updated and not adding a new menu..
for example I input a "bacon" and i put my desire prices on it.
however, if the program loops again and this time I input "Burger" and i put my desire prices on it.when the list is printed out again. the "bacon" was just being replaced by the "burger". how could I actually add a new item?
I Hope you get my problem fellas :D pls help mee
import java.io.*;
public class menu {
public static void main (String [] args)throws IOException{
BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
String[] newMenu=new String[100];
String[] newHalf=new String[100];
String[] newWhole=new String[100];
for(int i=0;;i++){
System.out.println("Enter your new menu input<Space> if your done");
newMenu[i]=read.readLine();
if(newMenu[i].equals(" "))
{break;}
System.out.println("Enter its Half Order");
newHalf[i]=read.readLine();
System.out.println("Enter its Whole Order");
newWhole[i]=read.readLine();
System.out.println("==== Menu List ====\n");
System.out.println("Beef Broccoli");
System.out.println("Whole:210 Half:185");
System.out.println("Stir Fried Beef");
System.out.println("Whole:245 Half:195");
System.out.println("Beef Stew");
System.out.println("Whole:215 Half:145 ");
System.out.println("Sweet and Sour Pork");
System.out.println("Whole:266 Half:155 ");
System.out.println("Crispy Pata");
System.out.println(newMenu[i]);
System.out.println("Whole:"+newWhole[i]+"Half:"+newHalf[i]);
}
}
}

