Тёмный

Java Number Guessing Game 

A J
Подписаться 3,1 тыс.
Просмотров 34 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@anismedini5967
@anismedini5967 4 года назад
I prefer my guessing game import java.util.Random; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Random random = new Random(); int toguess; int guess; toguess = random.nextInt(10); while (true) { System.out.println("Enter a Guess " ); guess = scanner.nextInt(); if (guess > toguess) { System.out.println("Your guess is too High"); } else if (guess
@LucasHeh
@LucasHeh 4 года назад
Enter a Guess ok Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at me.Lucas.idk.Main.main(Main.java:21)
@Muslim_YM.26
@Muslim_YM.26 2 года назад
import java.util.Random; import java.util.Scanner; public class g { public static void main(String[] args) { Random random=new Random(); Scanner input=new Scanner(System.in); int Limit; int Guess; int rand; System.out.println("Enter The Limit of Guessing"); Limit=input.nextInt(); rand=random.nextInt(Limit); for (int i=0;i
@lorencemanocasi8544
@lorencemanocasi8544 Год назад
Wow
@nikoteenie9641
@nikoteenie9641 Год назад
Loved this tutorial! So simple and made it so clear. I decided to also implement a randomized number for the secretNumber and when guessed correctly gave an output of how many guesses it took you to get to the correct one. Enjoy! :) import java.util.Scanner; //to take in user input import java.util.Random; //to create a random number public class GuessGame { public static void main(String[] args) { int secretNumber; // what the number is set to int userGuess; // the user input int guessCount = 0; // number of users guesses boolean correct = false; // set to false so that it's changed to true when guessed correctly Scanner keyboard = new Scanner(System.in); // so that we can use the user input //Creates the max and min number the object can randomly generate int maxNumber = 1000; int minNumber = 1; //Creates a random number object Random randomNumber = new Random(); //Attaches the random number object to secretNumber making it a short number secretNumber = minNumber + randomNumber.nextInt(maxNumber); //Loop through asking for numbers until the user guesses the secretNumber. // Create loop to move through the guesses while(!correct) { // while not false == true System.out.print("Guess the number that I am thinking: "); userGuess = keyboard.nextInt(); //takes input from the user if(userGuess == secretNumber) { // if guessed correctly correct = true; System.out.println("!!!YOU'RE A WINNER!!!"); System.out.println("It took you " +guessCount+ " guesses!");// includes number of wrong guesses } else if (userGuess < secretNumber){ System.out.println("GUESS HIGHER"); guessCount++; //counts wrong guesses } else if (userGuess > secretNumber) { System.out.println("GUESS LOWER"); guessCount++;//counts wrong guesses } } } }
@aceroeh173
@aceroeh173 4 года назад
I made so much complicated shit in my code and it just wouldn't work...guess i would be still struggling without you, Thank you!!
@pritamdavis
@pritamdavis 4 года назад
Such a simple and elegant tutorial. Impressive!!! :D
@CreepyStories433
@CreepyStories433 4 года назад
amazing tutorial but I have a problem, no matter what number I set up and no matter when I choose higher or lower than my initial number it always says higher, any way to fix that?
@zyayak
@zyayak 5 лет назад
how can be this game game over. if wrong guess number. many thanks
@Gabkun02
@Gabkun02 3 года назад
Can someone help me to this output... Guessing number but this next part of my output idont know how to do it.. 1. Create a try-catch structure that will handle two (2) exceptions. These are when the user inputs the following: * A number that is out of range (1 to 50) * A letter or any non-numeric character * Prompt the user that he can guess again if an exception thrown * Display the number of total guesses
@syahrillstudy7906
@syahrillstudy7906 2 года назад
Have tried it but there were an error " java: variable guess might not have been initialized " . What the solution to this problem?
@viperradiusbot8496
@viperradiusbot8496 2 года назад
How to random the number?
@axlecruz7494
@axlecruz7494 3 года назад
How about pin number?
@sherylen.2169
@sherylen.2169 2 года назад
thankyou so much!!
@mattjam1415
@mattjam1415 2 года назад
Mga it sa sti labas
Далее
Java Number Guessing Game
17:53
Просмотров 19 тыс.
pumpkins #shorts
00:39
Просмотров 30 млн
荧光棒的最佳玩法UP+#short #angel #clown
00:18
Learn Java in 14 Minutes (seriously)
14:00
Просмотров 4,8 млн
The Home Server I've Been Wanting
18:14
Просмотров 178 тыс.
Building a Guessing Game | Java | Tutorial 20
12:57
Просмотров 70 тыс.
Code the Hangman Game in Java
27:52
Просмотров 33 тыс.
Java For Beginners: While, Do While & For Loops (7/10)
10:59
pumpkins #shorts
00:39
Просмотров 30 млн