Thread: Help!!
View Single Post
Old Sep 30th, 2005, 1:11 PM   #1
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Help!!

How can i clear the screen after i choose to start a new game?
import cs1.Keyboard;
import java.util.*;

public class HiLo
{
    public static void main (String[] args)
    {
        int play = 1;
        while(play > 0)
        {
        Random generator = new Random();
        int answer = generator.nextInt(100)+1;
        //System.out.println(answer);
        //int play = 1;
        
        System.out.println("The computer is thinking of a number \nbetween 1 and 100. What is it?");
        int escape = 0;
        while(escape < 1)
        {
        int guess = Keyboard.readInt();
        
        if(guess == answer)
        {
            System.out.println("That's it");
            escape = 1;
        }
        else if(guess > answer)
        {
            System.out.println("Too High");
        }
        else if(guess < answer)
        {
            System.out.println("Too Low");
        }
        }
        
        System.out.println("Would you like to play again (y/n)");
        char again = Keyboard.readChar();
        if(again == 'y')
        {
            play = 1;
        }
        else if(again == 'n')
        {
            play--;
        }
    }
       
    }
}
crawforddavid2006 is offline