Lab 16 - April 8

 

To receive credit for this lab assignment, you must be finished by Friday, April 11, at 10:00 p.m. After this time you will not receive any credit.

 

Instructions:

1.  Login to UNIX, and write a program to do the following:

This lab will be useful (VERY useful) for the next programming assignment where you will implement a binary search.
 

You will generate a random number between 1 and 10 using the Math.random( ) function from JAVA.

Here is the JAVA function directly from: http://java.sun.com/j2se/1.3/docs/api/java/lang/Math.html

static double random()

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
 

The number that you get you will need to multiply by 10 to get an integer.  Since the function returns a double you will have to multiply by 10 and then cast to an int so it gets truncated.
 

You will give the user three chances to guess the number.
 

If the user guesses the number within three attempts, he/she will get a "Winner" message. If the user does not guess within three attempts, he/she will get a "Loser message".  Hint:  Uuse a while loop with two conditions :-)
 

3.  Send an e-mail in Pine and attach your program to the e-mail.  Send to the ics111-lab@hawaii.edu account.  Make sure the subject is 'lab 16'.

4.  Check the webpage to make sure that the e-mail arrived.  Here is the URL:

5.  Once I (TA) get the e-mail in my account AND I can verify it on the web, you will receive your lab participation point.

 

Link to the Java API -  to look up any methods of any class you would like to use.