Assignment #72 Again with the Number-Guessing
Code
///Name: Ian Grant
///Period:5
///Project Name: Again with the Number-Guessing
///File Name:Template.java
///12/04/15
import java.util.Scanner;
import java.util.Random;
public class NumGuessV5
{
public static void main(String[] args)
{
Scanner stuff=new Scanner(System.in);
Random Rstuff=new Random();
int gus,ans;
int tries=0;
ans= 1+Rstuff.nextInt(10);
System.out.println("teh worst number gessing gaaame evar!!");
System.out.print("I'm thinking of a number between 1 and 10. Try to guess it! ");
do
{
System.out.println("That is incorrect. Guess again.");
gus=stuff.nextInt();
tries++;
}
while (gus != ans);
System.out.println("That's correct! You're a good guesser");
System.out.println("It only took you "+tries+" tries.");
}
}
Output