The blanks are filled in in the program below.
Make sure that you used the right operator in the conditional expression part of
the if statement.
import java.util.Scanner;
class ComboLock
{
public static void main ( String[] args )
{
int lockFirst = 6, lockSecond = 12,
lockThird = 30; // The combination
int numb; // a user-entered number
Scanner scan = new Scanner( System.in );
boolean correct = true;
//First Number
System.out.print("Enter first number: ");
numb = scan.nextInt();
if ( numb != lockFirst ) // numb NOT EQUAL to lockFirst
correct = false ;
//Second Number
//Third Number
//Result
if ( correct )
System.out.println("Lock opens");
else
System.out.println("Lock does not open");
}
}
The program needs to deal with the next two numbers of the combination.
Decide on a general stategy for completing the program.