Question
What am I doing wrong??? import java.util.Scanner; public class GuessingGameV1 { public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); int count =
What am I doing wrong???
import java.util.Scanner;
public class GuessingGameV1 {
public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); int count = 0; int secretNumber; secretNumber = (int) (Math.random() * 99 + 1); int guess = 0;
System.out.println("Welcome to the Guess the Number Game "); System.out.println("+++++++++++++++++++++++++++++++++++++ "); System.out.println(); System.out.print("I'm thinking of a number between 1 and 100, try to guess it?!: ");
//Checking guess if (guess < game.getNumber()) // If guess is less than random number { System.out.println("Your guess is too low. "); } else if ((guess - game.getNumber()) > 10) // users guess is more than 10 higher than the random number { System.out.println("Way too high! "); } else if (guess > game.getNumber()) // If guess is greater than random number { System.out.println("Your guess is too high. "); } else // Correct Guess { }
//Incrementing guess count game.incrementGuessCount(); } }
/** * * @author Stephen */ public class Loworhigh;{
{ } catch (NumberFormatException e) static { //Handling exceptions System.out.println(" Invalid Number "); } } System.out.println("Correct! "); System.out.println("You guessed the correct number in " + game.getGuessCount() + " guesses. "); //Printing message based on number of guesses if(game.getGuessCount() <= 3) System.out.println("Great work! You are a mathematical wizard."); else if(game.getGuessCount() > 3 && game.getGuessCount() <= 7) System.out.println("Not too bad! You've got some potential."); else System.out.println("What took you so long? Maybe you should take some lessons"); System.out.println(" Bye! "); } }
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