Java Basics Class Help

Discussion in 'Homework Help' started by Viet, May 7, 2013.

Java Basics Class Help
  1. Unread #1 - May 7, 2013 at 4:30 PM
  2. Viet
    Joined:
    Jun 16, 2012
    Posts:
    1,164
    Referrals:
    0
    Sythe Gold:
    550
    Discord Unique ID:
    685231232916652047
    Discord Username:
    the_mule.
    Doge (2) RsProd (2) Lawrence Homosex Gohan has AIDS MushyMuncher

    Viet Guru
    withreal14 Donor

    Java Basics Class Help

    Can anyone help me with this assignment?

    http://azfoo.net/gdt/csc110/assignments/GuessingGame.html

    Code:
    	Specification
    
    Write a program that allows the user to play number guessing games.
    
    	Playing a Guessing Game
    Use class Random to generate a random number between 1 and 110 (inclusive). Prompt the user to enter a guess. Loop until the user guesses the random number or enters a sentinel value to give up. Print an error message if the user enters a number that is not between 1 and 110. Print an error message if the user enters a wrong guess more than once. Duplicate wrong guesses count as only one wrong guess. After five wrong guesses, the user is given help (higher or lower messages). After a game has been completed prompt the user to see if they want to play again. The user is allowed to play at most 256 games.
    
    	Post Game Playing Processing
    Print the following prior to exiting the program.
    
    number of games played
    number of games won
    winning percentage
    
    
    	Required Manifest (Named) Constants
    Your program must define the following manifest constants prior to the main() method and they should be used through your code.
    
       private static final int MIN_NUMBER = 1;
       private static final int MAX_NUMBER = 100;
       private static final int EXIT_VALUE = -1;
       private static final int MAX_GAMES = 256;
    
    
    	Help Generating Random Number
    Instantiate a class Random objecting using the current time on the computer as a seed.
    
       Random rg = new Random(System.currentTimeMillis());
    
    Generate a random between MIN_NUMBER and MAX_NUMBER.
    
       int n = MIN_NUMBER + Math.abs(rg.nextInt() % (MIN_NUMBER - MAX_NUMBER));
       // note: Math.abs(number) is the absolute value method.
    
    
    	Example Game
    Assume the computer generated random number is 34 for game #1, 73 for game #2, and 99 for game #3. For example purposes, user inputs are enclosed in brackets <>.
    
    *** You are playing the CSC110 Guessing Game ***
    
    Enter a number between 1 and 110 (-1 to give up): <3>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <1001>
    1001 is too big...
    Enter a number between 1 and 110 (-1 to give up): <0>
    0 is too small...
    Enter a number between 1 and 110 (-1 to give up): <33>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <50>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <21>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <21>
    what part of nope don't you understand?
    Enter a number between 1 and 110 (-1 to give up): <41>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <27>
    nope...higher
    Enter a number between 1 and 110 (-1 to give up): <57>
    nope...lower
    Enter a number between 1 and 110 (-1 to give up): <34>
    *** GOT IT *** it took you 8 guesses
    
    Do you want to play again? (y/n): <y>
    
    Enter a number between 1 and 110 (-1 to give up): <99>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <-1>
    *** QUITTER ***
    
    Do you want to play again? (y/n): <y>
    
    Enter a number between 1 and 110 (-1 to give up): <21>
    nope...
    Enter a number between 1 and 110 (-1 to give up): <99>
    *** GOT IT *** it took you 2 guesses
    
    Do you want to play again? (y/n): <n>
    
    Thanks for playing the CSC110 guessing game.
    
    You played 3 games and won 2 of them.
    Your winning percentage is 66.7%.
    
     
< Hamlet's Relationship with his mother, Gertrude, HELP PLEASE! | Orgo multiple choice problems >

Users viewing this thread
1 guest


 
 
Adblock breaks this site