import javax.swing.
*;
import java.util.Scanner;
public class Main{
public static void main(String[] args){
char guess;
Scanner input = new Scanner(System.in);
String phraseSolution = "EDUCATION";
StringBuilder phrase = new StringBuilder("ED??A??ON");
System.out.print("Current Word: " + phrase + "\n");
while(!phraseSolution.equals(phrase.toString())){
System.out.print("Enter your guess letter: ");
guess = Character.toUpperCase(input.nextLine().charAt(0));
boolean check = check(guess, phraseSolution);
if (check){
int spot = placeLocator(guess, phraseSolution);
phrase.setCharAt(spot, guess);
System.out.println(phrase);
System.out.println("Correct! \n\nEnter guess letter again");
}
else{
System.out.println("Sorry! This letter is not in the word please
guess another!\n");
}
}
System.out.print("\n\nCongrats! You found all letters and finished the
game!");
}
public static int placeLocator(char input, String phraseSolution){
int place;
int x = 0;
while(input != phraseSolution.charAt(x)){
x++;
}
place = x;
return place;
}
public static boolean check(char input, String phraseSolution){
boolean validation = false;
int letter = 0;
for(int x = 0; x < phraseSolution.length(); x++){
if(input != phraseSolution.charAt(x)){
validation = false;
}
else {
validation = true;
letter++;
}
}
if(letter >= 1) {
validation = true;
}
return validation;
}
}