No, not in any one run of the program. Like a combination lock, any wrong number will cause the lock to fail to open.
Here is the program with some additional details filled in, and some details that you are to fill in:
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 ( )
correct = ;
//Second Number
//Third Number
//Result
if ( correct )
System.out.println("Lock opens");
else
System.out.println("Lock does not open");
}
}
The program uses variables lockFirst, lockSecond,
and lockThird rather than using literal integer
values so that the programmer can easily change the combination.
Fill in the blanks so that the program checks the first number.