import java.io.*;
import java.util.Random;
public class Recursion
{
private static int ErroR(int userNum)
{
try
{
if(userNum < 0 ){System.out.println("\nERROR\n-----------------------\nNo Numbers Lower then 0\n-----------------------\nPlease Start Over");}
if(userNum > 100 ){System.out.println("\nERROR\n--------------------------\nNo Numbers Higher then 100\n--------------------------\nPlease Start Over");}
}
catch (NumberFormatException e){System.out.println("\nERROR\n--------------\nInvalid Answer\n--------------\nPlease Start Over");}
catch (NullPointerException e){System.out.println("\nERROR\n--------------\nInvalid Answer\n--------------\nPlease Start Over");}
return userNum;
}
private static int GuessNum(int userNum, int randNum)
{
{
/* The number is to High, to Low, or Exact */
if(userNum < randNum){System.out.println("Go Higher!");}
else if(userNum > randNum){System.out.println("Go Lower!");}
else if(userNum ==randNum){System.out.println("You got it, YOU WIN!)");}
return userNum;
}
}
public static void main (String[] args)throws IOException
{
int userNum, randNum;
String input;
BufferedReader keyboard = new BufferedReader (new InputStreamReader(System.in));
/* Generates random number */
final int Max_Num = 100;
Random ranGenerator = new Random();
randNum = ranGenerator.nextInt(Max_Num);
System.out.println("Hello!, and welcome to the guessing game. \nThe computer will generate a random number from 0 to 100 for you, \nand you will try to guess the number by entering a WHOLE NUMBER. \nIf you do not guess the number in 5 turns, GAME OVER! \nIf you guess the number in 5 turns, YOU WIN!\nGOOD LUCK!");
for(double guess=1; guess<=4; guess++)
System.out.print( "\nGuess a Number: " );
userNum = Integer.parseInt(input = keyboard.readLine().trim());
}
}
This post has been edited by ProGraM: 25 October 2006 - 02:16 PM

New Topic/Question
Reply


MultiQuote





|