JAVA
Develop a letter guessing game in this assignment using Java. Requirements: 1). When the game is started, generate a random letter between A and Z; 2). Display a message "I have a secret letter (A to Z), can you guess what it is?"; 3). Read the user's answer; 4). Compare the user's answer and the random secret letter generated; 5). If the user answer is before the random secret letter in the alphabet, display "Incorrect. Try something bigger" and go to Step 2; 6). If the user answer is after the random secret letter in the alphabet, display "Incorrect. Try something smaller" and go to Step 2; 7). If the user answer is the same as the random secret letter, display "Well done. Want to play again (y/n)?"; 8). Read the user's answer. If the answer is 'y', go to Step 1. If the answer is 'n', go to Step 9; 9). Display "Thanks for playing the game. Goodbye!". The program stops.
Code:
import java.util.*;
public class LetterGuessing {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String choice;
do{
choice="y";
System.out.println("I have a Secret Letter (A-Z) Can you guess
it?");
String user_letter=scan.nextLine();
char
input_letter=Character.toUpperCase(user_letter.charAt(0));
char[] chars
={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int[]
range={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26};
int user_int=0;
int user_loop=0;
char rand_letter=chars[(int)(Math.random()*26)];
int comp_int=0;
for(int i=0;i<chars.length;++i)
{
if(rand_letter==chars[i])
{
comp_int=range[i];
}
}
//this loop is for getting the int value of user inputted
letter
for(char i:chars)
{
if(input_letter==i)
{
user_int=range[user_loop];
}
++user_loop;
}
//test the entered letter of user
if(input_letter==rand_letter)
{
System.out.println("Correct Guess");
System.out.println("The letter is:"+rand_letter);
System.out.println("Do you want to
play again?(y/n)");
choice=scan.next();
}
//test the entered letter of user if greater than computer
input
else if(user_int>comp_int)
{
System.out.println("Incorrect Guess");
System.out.println("Try Something Smaller");
System.out.println("The letter is:"+rand_letter);
continue;
}
//test the entered letter of user if lesser than computer
input
else if(user_int<comp_int)
{
System.out.println("Incorrect Guess");
System.out.println("Try Something higher");
System.out.println("The letter is:"+rand_letter);
continue;
}
}
while(choice.equalsIgnoreCase("y"));
}
}
Output:
JAVA Develop a letter guessing game in this assignment using Java. Requirements: 1). When the game...
Using C programming
REQUIREMENTS: This program is a letter guessing game where a simple Al opponent generates a secret letter for the user to guess. The user must be able to take turns guessing the secret letter, with the Al responding to the user's guesses. After successfully guessing, the user must be allowed to play again. The Al must count how many turns the user has taken. Here is an example of a game in progress where the human user...
Write a Java application program that plays a number guessing game with the user. In the starter code that you are given to help you begin the project, you will find the following lines of code: Random generator = args.length == 0 ? new Random() : new Random(Integer.parseInt(args[0])); int secret = generator.nextInt(100); You must keep these lines of code in your program. If you delete these lines, or if you change thse lines in any way, then your program...
Word Guessing Game Assignment Help Needed. This C++ (I'm using Visual Studio 2015) assignment is actually kind of confusing to me. I keep getting lost in all of the words even though these are supposed to instruct me as to how to do this. Can I please get some help as to where to start? Word guessing game: Overview: Create a game in which the user has a set number of tries to correctly guess a word. I highly recommend...
The game must be done in java in Netbeans
1. Write a Guessing Game. In the game, the user will guess a number. a. In the StartGui, the use needs to choose a difficulty level: Easy or Difficult. If easy level is selected, the user will guess between 1 and 10. If difficult level is selected, the user will guess 1 and 100. Then the user will click Start button and go to the GamePage. b. In the GamPage, the...
c++ launguage please help The game Pico Fermi Bagel is a number guessing game. The computer picks a secret number: the secret number must be 3 digits, none of the digits can be the same, and it cannot start with a zero. 104 is OK, but 091 and 212 are not. The user tries to guess the secret number - if none of the digits in the user's number are in the secret number, then the program replies with BAGEL...
Create a script that presents a word guessing game. Allow users to guess the word letter-by-letter by entering a character in a form. Start by assigning a secret word to a variable named $secret. After each guess, print the word using asterisks for each remaining letter but fill in the letters that the user guessed correctly. You need to store the user’s guess in a hidden text field name $hidden_guess. For example, if the word you want users to guess...
Lab #6 Number Guessing Game – Loops and Nested Loops Requirements: Design, develop, test, and submit a program for a Number Guessing game. The program will select a random number between 0 and 100, allow the user to try up to 10 times to guess the number, and tell the user if each guess is too high, too low, or correct. The actual game portion must be a function...you can use more than one function in your program. The amount...
please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then write each user guess and answer to the file. (on separate lines) Write the number of guesses to the file at the end of the game. After the game is finished, ask the user if they want to play again. If 'n' or 'N' don't play again, otherwise play again! NOTE: your file should have more than one game in it if the user...
Create a new program, WordGuessingGame. Using a while loop, create a game for the user. The game requires the user to guess a secret word. The game does not end until the user guesses the word. After they win the game, they are prompted to choose to play again. The secret word that user must guess is "valentine". It is a case-sensitive analysis With each guess... If the guess does not have an equal number of characters, tell the user...
Write a JAVA program that plays a number guessing game with the user. A sample run for the game follows. User input is shown in boldface in the sample run. Welcome to the game of Guess It! I will choose a number between 1 and 100. You will try to guess that number. If your guess wrong, I will tell you if you guessed too high or too low. You have 6 tries to get the number. OK, I am...