Nikon SLR Cameras

Java 'Hangman' programming homework

Howard
Howard

I'm doing a java homework program where you have 20 random words and it randomly chooses 1 of the twenty, after that you have to guess the word hangman style (with 10 lives), and assuming the word is Telephone it would first appear like _ _ _ _ _ _ _ _ _ and say you enter in a guess "e", it would become _ e _ e _ _ _ _ e and then guess "t", t e _ e _ _ _ _ e, this is suspose to be using simple console programming. From what i have done so far the program runs once and won't work a second time if i loop it again.

Here's the code i have done so far

import hsa.*;
import java.util.Random;

public class Whatistheword {
public static void main(String[] args){
Console con = new Console ();

String mword="";
String guess="";
Random r = new Random();
int length;
int count=0;
int intx1=0;
int intx2=1;
String check;
int letter=0;
int life = 10;
int check2 = 0;

con.println ("Welcome to the 'What is the Word?' Game");
pause (1000);

// Array of 20 words & chooses one of the twenty
String[] listOfWords = {"IpodTouch","Blackberry","Apple","Samsu…
int randint = r.nextInt(listOfWords.length);
mword = listOfWords[randint];

// so i know what the word is to test
con.println("The Random word is: "+mword);
length = mword.length();
con.println (mword);
con.println (length);

con.println ("Guess a letter for the word!");
guess = con.readLine();
// runs to check letters individually
while (count ≠ length){

count = count + 1;
check = mword.substring(intx1, intx2);
intx1 = intx1 + 1;
intx2 = intx2 + 1;
if (guess.equalsIgnoreCase(check. {
letter = letter + 1;
con.print (guess);
// prints this if letter wasn't guessed
}else {

con.print (" _ ");
}

}

}
public static void pause(int intMS){
try{
Thread.sleep(intMS);
}catch(InterruptedException e){
}
}
}

Guest
Guest

Http://docs.oracle.com/javase/tutorial/

Guest
Guest

We purchase virtual currency gold. If you want selling it. You can coming igcoin.com. We will offer the best price.