// The "GuessTheWord" class.
import hsa.*;
public class GuessTheWord
{
public static void main (String[] args)
{
char[] letter={'h','i','p','p','o','p','o','t','a','m','u','s'};
int wordSize, count, x;
char guess;
boolean[] flag;
count = 0;
wordSize = letter.length;
flag = new boolean[wordSize];
for(x= 0; x< wordSize; x++)
{
flag[x] = false;
}
do
{
Stdout.println("Enter a letter");
guess = Stdin.readChar();
for(x=0; x<wordSize; x++)
{
if(flag[x] == true)
{
Stdout.print(letter[x]+" ");
}
else if(guess == letter[x])
{
Stdout.print(letter[x] + " ");
flag[x]= true;
count = count + 1;
} // endif
else
{
Stdout.print("_ ");
}
} //end loop for finding matching letters
Stdout.println();
} // end of do loop
while (count<wordSize);
} // main method
} // GuessTheWord class
that is the program i had made earlier and i must learn to modfiy in the follwing way-. Input from Data files
Modify your “Guess the Word” program to read in the mystery word from a data file.
The data file should contain 10 mystery words. The program randomly picks one of the words to solve.
BONUS: See if you can make the program ask the user if she/he wants to play another round.
i have no idea how to do this and must learn brfore we recive the final project. so could someone please help. thanks

New Topic/Question
Reply



MultiQuote








|