import java

import java.util.Scanner;

public class Lab_2{

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

public static void main(String args) {
Scanner input = new Scanner(System.in);

String play = “y”;
do {

char word = getWord();

char space = new charword.length;
fill(space);

int missed = 0;
do {
char guess = getGuess(space);
if (!Check(word, space, guess))
missed++;

} while (!Finish(space));
print(word, missed);

System.out.println(“\nDo you want to guess another word? Enter y or n “);
play = input.next();

} while (play.charAt(0) == ‘y’);
}

public static char getWord() {
String words = {“write”, “that”, “program”, “mad”, “java”, “grant”,
“norris”, “crosscode”};

String Word = words(int) (Math.random() * words.length);
char letters = new charWord.length();

for (int i = 0; i < letters.length; i++) {
lettersi = Word.charAt(i);
}
return letters;
}

public static void fill(char list) {
for (int i = 0; i < list.length; i++) {
listi = '*';
}
}

public static boolean Check(char word, char blanks, char guess) {
boolean correct = false;
int missCheck = 2;
for (int i = 0; i 0)
print(missCheck, guess);
return correct;
}

public static boolean Finish(char blanks) {
for (int i = 0; i < blanks.length; i++) {
if (blanksi == '*')
return false;
}
return true;
}

public static void print(char word, int missed) {
System.out.print("The word is ");
System.out.print(word);
System.out.print(" you geussed wrong " + missed +" times");

}

public static void print(int check, char guess) {
if (check == 0) {
System.out.println(" is already in the word");
}
if (check ==1) {
System.out.println(" is not in the word");
}
}

public static char getGuess(char asterisks){
Scanner input = new Scanner(System.in);
System.out.print("Geuss a letter please ");
System.out.print(asterisks);
System.out.print( " Your Geuss: ");
String geuss = input.next();
return geuss.charAt(0);
}
}

You Might Also Like
x

Hi!
I'm Alejandro!

Would you like to get a custom essay? How about receiving a customized one?

Check it out