Java Problem

Networking/Security Forums -> Programming and More

Author: truly_hacking PostPosted: 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*****************************");
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();
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');

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!!

Author: ShaolinTigerLocation: Kuala Lumpur, Malaysia PostPosted: Tue Oct 29, 2002 6:20 pm    Post subject:
Each time someone buys something, put the value of that into an array, when they choose 5 just print out the contents of the array and exit.

I'm not a big Java fan though, so in coding terms I'm not sure how this would be done.

Author: browolf PostPosted: Tue Oct 29, 2002 10:23 pm    Post subject:
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.

here's a good example page.



Networking/Security Forums -> Programming and More

output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group