Posted: Tue Oct 29, 2002 6:12 pm Post subject: Java Problem
Im new to programming and i have a question i cant get my head round.. can anyone help?
here is the code ive done so far
public class vend
{
public static void main(String[] args)
{
char group, selection;
System.out.println("*****************************\n***Please make your choice***\n*****************************");
do
{
System.out.println("[1] Get Gum ");
System.out.println("[2] Get Chocolate ");
System.out.println("[3] Get Popcorn ");
System.out.println("[4] Get Juice ");
System.out.println("[5] Display Items Sold ");
System.out.print("Please Enter your selection : ");
selection = EasyIn.getChar();
System.out.println();
switch(selection)
{
case '1' : System.out.println("Here is your Gum!");break;
case '2' : System.out.println("Here is your Chocolate!");break;
case '3' : System.out.println("Here is your Popcorn!");break;
case '4' : System.out.println("Here is your Juice!");break;
case '5' : System.out.println("Here is your selection : ");break;
default: System.out.println("Error, options 1-5 only");
}
}while (selection != '5');
System.out.print(selection);
}
}
However i need to make it so when the user enters 5 the program gives them a list of the items they have selected so far and then exit. Please could someone help becouse i have no idea how to do this!!
the solutions in problems often comes from figuring out what code structures to use eg array, if then else, while etc. the actual details in the specific language can come later.
When i did programming stuff at uni, we was always taught to do stuff in "pseudocode" first.
It's really good cos when u can conceptulise programs/scripts in pseudocode, you're halfway there regardless of which programming language you're gonna use.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
Featured Links*
Looking for more Windows Networking info?
Sign up to the WindowsNetworking.com Monthly Newsletter, written by Enterprise Security MVP Deb Shinder, containing news, the hottest tips, Networking links of the month and much more. Subscribe today and don't miss a thing! View a sample newsletter.
Become a WindowsNetworking.com member!
Discuss your Windows Networking issues with thousands of other Windows Newtorking experts. Click here to join!