Assignemnt #66 Hi Lo With Limited Tries
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Hi Lo With Limited Tries
///File Name: HLWLT.java
import java.util.Random;
import java.util.Scanner;
public class HLWLT
{
public static void main( String[] args )
{
Scanner momo= new Scanner(System.in);
Random r =new Random();
int choice=1+ r.nextInt(100), guess;
System.out.println ( " Guess a number between 1-100. You have 7 guesses." );
guess=momo.nextInt();
tries++;
if ( guess==choice )
{
System.out.println( " wow youre right." );
}
while ( guess != choice && tries < 7 )
{
else if ( guess > choice)
{
System.out.println( "Sorry you were to high. It was " + choice + "." );
}
else if ( guess < choice)
{
System.out.println( "Sorry you were to low. It was " + choice + "." );
}
}
}
}
Picture of Output