## import go through to check if it is

import java.util.Scanner;import java.util.Random;import java.lang.System;////   Taylor Rochon//   Computer Science Final Culminating Project//   January 2018//public class NumGuessingGame {    public static void main (String args){        //                          *INTRO TO GAME*        //         // User will guess a random number of any length and will keep guessing and        // using the hints provided (whether it is too high or low) and the program         // will keep track of how many times user has guessed and at the end of the        // game it will display win or lost and how many guesses it took to find        // the right number.              System.out.print(“Welcome.
“);        System.out.print(“You are now playing a game that will give you a random generated number between 1 and the number you chose
“);        System.out.print(“Choose wisely:

“);        Scanner scan = new Scanner(System.in);  // This is the number the user will input of the start of the game so the computer knows the limit on where it generates a number        int max;        max = scan.nextInt();        Random randomNum = new Random();        int num = randomNum.nextInt(max);        int tries = 0; // This number will change (or stay the same) depending on how many guesses the user takes to find the unknown number        Scanner input2 = new Scanner(System.in);        int guess;        boolean playerWin = false;        while (playerWin == false){  // This while loop keeps repeating until the user guesses the right number            System.out.print (“Now start guessing between 1 “+ num +”:
“);            guess = input2.nextInt();            tries++; // Refers back to tries = 0 will keep adding 1 to the guess count until the user gets it right            if (guess == num){                playerWin = true; // This is the first thing the input number will go through to check if it is a winning number or not                                  // If the number is guessed first try playerWin = true and the game will end if not it will keep going through the loop                                              }            else if(guess < num){                System.out.print("Your guess was too low, try again!");                                 // Second phase of the loop the number is checked to see if it was too low or too high                                 // If too low the player will be prompted to guess again            }            else if(guess > num){                System.out.print(“Your guess was too high, try again!”);                                 // Third phase of the loop the number is checked to see if it was too low or too high                                  // If too low the player will be prompted to guess again            }        }                                 // When the user gets the correct number the text below will print out        System.out.print(“Congratulations!! You have won the game /n”);                   if (tries < 5)             System.out.print(" Wow, Less than 5 tries!! You guessed it in " +tries+ " ");                      else (tries > 5)             System.out.print(” Good job! You have beat the game in ” +tries+ “, if you try again aim for less than 5 attempts!”            }}

### Best services for writing your paper according to Trustpilot

From \$18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From \$13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From \$20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team
x

Hi!
I'm Isaac!

Would you like to get a custom essay? How about receiving a customized one?

Check it out