Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com >>>Java Help(newbie) with guess my number!!!!!
 User Name Remember Me? Password

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 09-11-2013, 12:55 AM PM User | #1 makkhay New to the CF scene   Join Date: Sep 2013 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts >>>Java Help(newbie) with guess my number!!!!! /** hello, I have problem with looping the program. My code doesn't loop as I expect. By the way logic is fine, just loop isn't working!! Any help and suggestions would be appreciated. I want to display the following result; Guess a number between 1- 100 is it 50? (h/c/l): l is it 25? (h/c/l): c Do you want to play again(y/n):y Guess a number between 1- 100 is it 50? (h/c/l): h is it 75? (h/c/l):c do you want to play again?(y/n): n */ PHP Code: ``` import java.util.Scanner;public class GuessingGame {   public static void main(String[] args)   {      int max=100;      int min=0;      int mid=50;      String inp=" ";      char playAgain=' ';        char choice=' ';Scanner in=new Scanner(System.in);do{    System.out.println("Guess a number between 1 - 100.");           while(choice!='c') {    System.out.print("is it "+mid+"?" + " (h/l/c)");    choice=in.next().charAt(0);    if(choice =='l')    {        max=mid;        mid=(min+mid)/2;    }    if(choice =='h')    {        min=mid;        mid=(max+mid)/2;    } }       System.out.println("Great! Do you want to play again? (y/n): "  );     playAgain = in.next().charAt(0);       }while(playAgain!='n');  }}  ``` Last edited by Fou-Lu; 09-11-2013 at 02:40 AM..
 09-11-2013, 02:39 AM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,597 Thanks: 4 Thanked 2,597 Times in 2,566 Posts There's a forum for java so I'll move this there. Which loop isn't looping, the outer or the inner? __________________ PHP Code: ``` header('HTTP/1.1 420 Enhance Your Calm');  ```

 Bookmarks

 Tags computer programming, java

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 11:35 AM.