Hi, i am in need of some help with an assignment.
The Question : Write a program which will think of a word and ask the user to guess the word. The user may guess a letter at a time and your program will print out wherever the letter occurs. If the user guesses incorrectly, they lose a point. If they lose 8 points, they lose the game. If the user guess correctly, then you show where the letter occurs in the word.
My code so far :
public class WordGuess
{
public static String getRandomWord()
{
String [] words = {"keyboard", "mouse", "monitor", "ram", "cpu", "processor", "google", "website", "megabyte", "gigabyte" };
int randomIndex = (int) (Math.random() * words.length);
return words[randomIndex];
}
public static void main (String [] args)
{
for(int i = 0; i < words.length; i++)
{
System.out.println (words[i]);
}
}
}
I know its not much but im kind of stuck so any tips would be nice, thanks :)