Assignemnt #61 Number Guessing With Counter
Code
///Name: JJ Deng
///Program Name: Number-Guessing with a counter
///File Name: NumberGuessingCounter.java
///Period: 6
///Date Finished: 1/7/16
import java.util.Random;
import java.util.Scanner;
public class NumberGuessingCounter
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int choice = 1 + r.nextInt(10), Number, count=0;
String response = "";
System.out.println("YO HOMIE GUESS THE MFING BRAH ");
System.out.println();
System.out.print("AYE YO MAN DA NUMBA IS B2WEEN 1-10 ");
Number = keyboard.nextInt();
System.out.println();
count++;
while ( Number!= choice )
{
System.out.println("That is incorrect. Please try again." );
Number = keyboard.nextInt();
System.out.println("");
count++;
}
System.out.println("Congrats! You got it right. It took you " + count + " times." );
}
}
Picture of the output