X hits on this document

159 views

0 shares

0 downloads

0 comments

27 / 46

© S. Uchitel, 2004

27

Guess Program

import java.util.Random;  

import kenya.io.InputReader;

public class Guess {

//Implements the “guess-what-number-I’m-thinking of” game

public static void main(String [] args) {

 Random generator = new Random();

 int number = generator.nextInt(10)+1;

//Pick a number randomly between 1 and 10

 System.out.println(“Take a guess (1 to 10)”);

 if (number == InputReader.readInt())

System.out.println(“You win”);

 else

System.out.println("It was " + number + ", tough Luck");

}

}

Document info
Document views159
Page views159
Page last viewedSat Jan 21 23:55:05 UTC 2017
Pages46
Paragraphs816
Words2901

Comments