X hits on this document

106 views

0 shares

0 downloads

0 comments

35 / 46

© S. Uchitel, 2004

35

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");

}

}

Why did I

add this?

Why do we need

this?

Document info
Document views106
Page views106
Page last viewedMon Dec 05 19:17:35 UTC 2016
Pages46
Paragraphs816
Words2901

Comments