This lab is going to be a little different than the previous "step-by-step" lab from last week. In this lab, I will give you some specifications and you will need to write a program that meets those specifications. Don't worry, I'll give you some hints to help you.
A user tries to guess a number from 1 to 100. He gets 10 guesses to do it.
Because a picture is worth a thousand words, here's an example of output from a working program:
Guess a number between 1 and 100 (10 guesses left): 50 Too low, try a higher number Guess a number between 1 and 100 (9 guesses left): 75 Too low, try a higher number Guess a number between 1 and 100 (8 guesses left): 87 Too low, try a higher number Guess a number between 1 and 100 (7 guesses left): 93 Too high, try a lower number Guess a number between 1 and 100 (6 guesses left): 90 You guessed it! Want to play again? (y/n) n
int number = (int)(Math.random() * 100) + 1;
No need to import anything.
System.out.println("message...");
int var = 5; System.out.println("var=" + var);
Use the EasyInput class that I wrote for you. The I/O classes in Java are a bit bewildering, this helper class should make life easier for you. Using it is simple:
String str = EasyInput.readString(); char c = EasyInput.readChar(); int i = EasyInput.readInt(); double d = EasyInput.readDouble();
Just drop the EasyInput.java file in the same directory as your lab assignment, compile your lab and it will all just magically work; no need to import anything. Piece of cake. The source code is there if you want to look at it.