Will Pay for Help

The highlighted part is the problem but idk how to stop it from happening
import java.util.Scanner;
import java.util.Random;

public class GuessANumber {

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

System.out.print("Enter a random seed: ");
int seed = input.nextInt();
random.setSeed(seed);
int target = random.nextInt(200) + 1;
System.out.println("DEBUG: The number picked is: " + target);

int guess = 0;
int count = 0;
while (guess != target) {
System.out.print("Enter a guess between 1 and 200: ");
guess = input.nextInt();
count++;

if (guess < 1 || guess > 200) {
System.out.println("Your guess is out of range. Pick a number between 1 and 200.");
} else if (guess != target) {
System.out.println("That is not the number.");
}
}

System.out.println("Congratulations! Your guess was correct!");
System.out.println("I had chosen " + target + " as the target number.");
System.out.println("You guessed it in " + count + " tries.");
}
}
import java.util.Scanner;
import java.util.Random;

public class GuessANumber {

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

System.out.print("Enter a random seed: ");
int seed = input.nextInt();
random.setSeed(seed);
int target = random.nextInt(200) + 1;
System.out.println("DEBUG: The number picked is: " + target);

int guess = 0;
int count = 0;
while (guess != target) {
System.out.print("Enter a guess between 1 and 200: ");
guess = input.nextInt();
count++;

if (guess < 1 || guess > 200) {
System.out.println("Your guess is out of range. Pick a number between 1 and 200.");
} else if (guess != target) {
System.out.println("That is not the number.");
}
}

System.out.println("Congratulations! Your guess was correct!");
System.out.println("I had chosen " + target + " as the target number.");
System.out.println("You guessed it in " + count + " tries.");
}
}
No description
3 Replies
JavaBot
JavaBot6mo ago
This post has been reserved for your question.
Hey @mixomi! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot6mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server