Read sections 4.1 to 4.9 of the text Computing Concepts with Java Essentials. This covers material on Java's branching statements: if and if-else.
Pay particular attention to Common Error 4.3 and Common Error 4.4 on pages 156-158.
Okay, for a change, no piglatin this week, but watch out for it coming back with a vengeance next week! For the in-lab exercise this week, we are going to write a program that plays with your if-else knowledge.
In the lab, you will perform an exercise on if-else statements. You will write a program that generates three random numbers (say, first, second and third) between 1 and 50, and answers the following questions on these numbers.
I heard! Since you have been talking about the labs being too long (remember for the last lab you had two weeks!), this time there will be only two problems for the lab. Read the following very carefully.
Okay, I have selected a number. You have four choices to guess it...
Enter your first guess.... 10
Nope, too big!
Enter your second guess.... 5
Nope, too small!
Enter your third guess.... 7
Nope, too small!
Enter your fourth and last guess.... 8
Sorry, my selected number was 9! Thanks for playing.
Name this program Youguess.java
Think of a number between 1 and 15. Hit return when ready
My first guess is: 8
Is this too (b)ig or too (s)mall or (c)orrect? s
My second guess is: 12
Is this too (b)ig or too (s)mall or (c)orrect? c
Yay!
Save this program as Iguess.java
For this lab, you should submit two files:
Do not submit .prj, .class or .html files. Only the files named above should be submitted.
In order to submit files, click on the following link to send mail to:
with the following Subject:
and then Attach your program files to the e-mail message. You may attach multiple files in the same message, but you don't have to. You can submit your programs in separate e-mails if you wish. Do not type anything in the body of the message! You must use the filenames specified in this assignment and you must attach the files to the mail message.