Results 1 to 5 of 5

Thread: Loop problem

  1. #1
    durdanto is offline Member
    Join Date
    Feb 2011
    Posts
    20
    Rep Power
    0

    Default Loop problem

    How do we display the number of guess (shown below) left out for user.

    i.e:

    I need to produce the folllowing:

    Word to date: **** (10 guess(es) left)
    Which letter should I check for? s

    Word to date: **** (9 guess(es) left)
    Which letter should I check for? n

    and so on...


    this is what i did so far:
    Java Code:
    // 10 guess for a player
    			
    for(int i=0; i < 10; i ++)
    			
    {
    				
      {
        System.out.println("Word to date: **** ("+ i + ("guess(es) left"));
        System.out.println ("Letters not tried yet: " + letters);
        String letter1 = kb.next();
       }
    }
    plz help

  2. #2
    durdanto is offline Member
    Join Date
    Feb 2011
    Posts
    20
    Rep Power
    0

    Default

    insted of giving me :
    10 guess left
    9 guess left
    8 guess left

    It's displaying 0, 1, 2 ...guess left

  3. #3
    Spyderpig is offline Member
    Join Date
    Feb 2011
    Posts
    24
    Rep Power
    0

    Default

    im new to java too but i think it should be i=10, i<10, i--

  4. #4
    Join Date
    Feb 2011
    Location
    Ahmedabad
    Posts
    36
    Rep Power
    0

    Default Loop problem

    revert the loop as follow
    Java Code:
    for(int i=10; i > 0; i --)
    {
    //your code
    }

  5. #5
    durdanto is offline Member
    Join Date
    Feb 2011
    Posts
    20
    Rep Power
    0

Similar Threads

  1. While loop problem
    By mochibon in forum New To Java
    Replies: 3
    Last Post: 04-18-2010, 08:21 PM
  2. simple line problem / for loop problem
    By helpisontheway in forum New To Java
    Replies: 1
    Last Post: 11-17-2009, 06:12 AM
  3. Problem with loop
    By Tykk in forum New To Java
    Replies: 7
    Last Post: 10-04-2009, 10:26 PM
  4. Loop Problem
    By jralexander in forum New To Java
    Replies: 4
    Last Post: 12-02-2008, 07:08 AM
  5. For loop problem
    By mcal in forum New To Java
    Replies: 32
    Last Post: 01-25-2008, 03:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •