Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 2012, 05:28 PM
soblers soblers is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 soblers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 40 sec
Reputation Power: 0
Not sure which type of loop to use

Hey,
As part of a project im doing, I want the user to input a choice from a menu(1,2,or3) if they pick one of these choices they get asked whether they want pick another item, if they pick yes they then pick another choice, if they pick no they leave this part of the screen. But I can't get the programm to keep running after they enter their choice for the 2nd time. I tried using a do while loop, but I got confused where to place "Do you want to order again". Here is my code for it.

The code tags made my code look worse?
Thanks
Quote:
public void yourChoice(){ String choicePizzaAsString; String continueAsString=""; int pizzaChoice; choicePizzaAsString=JOptionPane.showInputDialog("Please enter your choice:"); pizzaChoice=Integer.parseInt(choicePizzaAsString); if(pizzaChoice !=1 && pizzaChoice !=2 && pizzaChoice !=3) { choicePizzaAsString = JOptionPane.showInputDialog("Invalid choice-please re-enter"); } else { continueAsString=JOptionPane.showInputDialog("Would you like to order anything else y/n"); } if(continueAsString.equals("y")){ choicePizzaAsString = JOptionPane.showInputDialog("Invalid choice-please re-enter"); } else if(continueAsString.equals("n")){ JOptionPane.showMessageDialog(null,"Please select a pizza"); }}

Reply With Quote
  #2  
Old December 3rd, 2012, 02:38 AM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 1,534 tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 10th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 27 m 57 sec
Reputation Power: 1620
Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye Send a message via Google Talk to tvc3mye Send a message via Skype to tvc3mye
Facebook
Format your codes

Could you please format your codes properly using the CODE tag? It is really hard for us to read your codes and to catch any syntax errors with missing braces.

Please properly indent your codes to increase readability.
__________________
When the programming world turns decent, the real world will turn upside down.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Not sure which type of loop to use

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap