• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

Java Problem

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
truly_hacking
Just Arrived
Just Arrived


Joined: 03 Jul 2002
Posts: 0


Offline

PostPosted: Tue Oct 29, 2002 6:12 pm    Post subject: Java Problem Reply with quote

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!!
Back to top
View user's profile Send private message
ShaolinTiger
Forum Fanatic
Forum Fanatic


Joined: 18 Apr 2002
Posts: 16777215
Location: Kuala Lumpur, Malaysia

Offline

PostPosted: Tue Oct 29, 2002 6:20 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
browolf
Trusted SF Member
Trusted SF Member


Joined: 19 Apr 2002
Posts: 1


Offline

PostPosted: Tue Oct 29, 2002 10:23 pm    Post subject: Reply with quote

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.
http://www.unf.edu/~broggio/cop2221/2221pseu.htm



hth

Andy
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
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

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!

Community Area

Log in | Register

Readers' Choice

Which is your preferred data recovery solution?

Follow TechGenix on Twitter