import flow chart. } } //This is

import java.util.*;

//Java utilities are neccessary for the program to function.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!

order now

//Sydney Terrasi


//LAB 4 Guess

public class Guess {
public static void main(String args ) {
//I define my variables for the program in the main method. These varibales will applied to the while loop to build the game

int tries= 0;
int numberUserGuess;
Random integer = new Random();
int guess;
boolean playAgain;
int totalGames = 0;
int wins= 0;
Scanner input = new Scanner(;
int totalTries= tries + totalGames;

//This do while loop runs until the condition (the correctly guessed integer) is satisfied.
//Introduction to the program
do { numberUserGuess = integer.nextInt(50);
//Call for random integers up to 50.

guess= 0;
System.out.println(“Welcome to the integer guessing game!”);
System.out.println(“The number I have chosen for this game is between 1 and 100”);
System.out.println(“Take a guess!”);
while (numberUserGuess != guess) {
guess= input.nextInt();
//This statments says that the user can’t use any integers less than 1 or more than 100.
if (( guess ; 50 || guess numberUserGuess) {
System.out.println(“Incorrect! The number is lower than your guess!”);
} else if (guess ; numberUserGuess){
System.out.println(;Incorrect! The number is higher than your guess!;);

//These conditional statments allow the user to keep playing the game until the generated picked int. is guessed. Acts like a flow chart.


//This is the code for the results with their calculation and prompting the user, whether or not they liked to play again.

System.out.println(;YOU GUESSED IT!!! Congratulations you won!;);
System.out.println(;The correct number was: ; + numberUserGuess);
System.out.println(;It took you ; + tries + ; attempts;);
System.out.println(;Here are the Overall results:;);
System.out.println(;Total # of games played: ; + totalGames);
System.out.println(;Guesses over games: ; + tries/totalGames);
System.out.println(;Would you like to play again? (Y/N););
switch ( {
case ;Y;:
case ;y;:
case ;yes;:
case ;Yes;:
//Case allows the user to accept ;yes; in different forms, when prompted to play again.
playAgain= true;

System.out.println(;Thanks for playing!!! See ya soon!;);

} //End of main method.

} //End of program.


I'm Casey!

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

Check it out