Assignemnt #61 and keep guessing
Code
///name: nick cerdan
///period: 6
///program name: Keep guessing
///file name: kg.java
///date finished: 10/21/15
import java.util.Random;
import java.util.Scanner;
public class kg
{
public static void main(String[] args)
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int guess, snumber;
snumber = 1 + r.nextInt(10);
System.out.println("I'm thinking of a number between 1-10. Try to guess it!");
System.out.print("> ");
guess = keyboard.nextInt();
System.out.println("");
while (guess != snumber)
{
System.out.println ("Wrong, try again!");
System.out.print("> ");
guess = keyboard.nextInt();
System.out.println("");
}
System.out.println("congrats! You got it right! the number i was thinkin gof was " + snumber + " (but you already knew that!)");
}
}