1 Replies - 741 Views - Last Post: 11 June 2014 - 04:52 AM Rate Topic: -----

#1 salmander   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-June 14

i am not sure i cant figure this out?

Posted 10 June 2014 - 09:30 PM

/**
 * Auto Generated Java Class.
 */
import java.util.*;
public class Hangman {
  
  
  public static void main(String[] args) { 
    Scanner input = new Scanner (System.in);
    int guess;
    boolean revealed[] = {false, false, false, false, false};
    String word [] = {"c", "a", "n", "a", "d", "a"};
    String letter;
    while (guess > word.length){
      letter = input.next();
      if (letter.substring(guess, guess + 1)==word[guess] ){
        revealed [guess] = true;
        System.out.println(word[guess]);
      }
      else
      {
        System.out.println("you lost");
      }
      }
    }
  }
  
  /* ADD YOUR CODE HERE */
  
}


i am not sure how to make the program check if the letter entered by the user matches the one in the array. also i am not sure how to make the program run again with a new word.

This post has been edited by macosxnerd101: 10 June 2014 - 09:44 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: i am not sure i cant figure this out?

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: i am not sure i cant figure this out?

Posted 11 June 2014 - 04:52 AM

You're not really thinking about it properly. Even your textual description shows this. How many guesses is the user allowed, for instance?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1