Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how can i improve this file to account for space index when user enters a letter: import java.util.Scanner; public class Hangman { private static final
how can i improve this file to account for space index when user enters a letter: import java.util.Scanner;
public class Hangman
private static final boolean testingModetrue;
private static String level;
private static boolean keepPlayingtrue;
private static String hiddenWord;
private static int numGuesses;
private static int numSpaces;
public static void mainStringargs
Scanner consolenew ScannerSystemin;
whilekeepPlaying
System.out.printlnEnter your difficulty: Easye Intermediatei or Hardh;
levelconsole.nextLine;
whilelevel.equalsIgnoreCasee&&
level.equalsIgnoreCasei&&
level.equalsIgnoreCaseh
System.out.printlnNot a valid input";
levelconsole.nextLine;
Hanglevel console;
System.out.printlnWould you like to play again? Enter y or n to continue";
keepPlayingconsole.nextLineequalsIgnoreCasey;
System.exit;
private static void HangString level, Scanner console
String secretWordRandomWord.newWord;
iftestingMode
System.out.printlnThe secret word is: secretWord;
iflevelequalsIgnoreCasee
numGuesses;
numSpaces;
else iflevelequalsIgnoreCasei
numGuesses;
numSpaces;
else iflevelequalsIgnoreCaseh
numGuesses;
numSpaces;
forint i; i secretWordlength;i
hiddenWord;
System.out.printlnThe word is: hiddenWord;
whilehiddenWord.equalssecretWord
System.out.printPlease enter the letter you want to guess: ;
String guessconsole.nextLine;
System.out.printlnPlease enter the spaces you want to check seperated by spaces: ;
numSpacesconsole.nextInt;
console.nextLine;
ifguesslengthCharacter.isLetterguesscharAt
System.out.printlnYour input is not valid. Try again";
System.out.printlnGuesses remaining: numGuesses;
else
char letguess.charAt;
for int i;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started