Write a program that does deals with passwords.
A password for this problem is valid only if it’s in [4834..7483) or (89233..923182].
[ mean inclusive and ( means exclusive
Don't let the user keep going until a valid password has been entered.
Then and only then say WELCOME.
import javax.swing.JOptionPane;
public class password {
public static void main(String[] args) {
final double RANGE1_MIN = 4834;
final double RANGE1_MAX = 7483;
final double RANGE2_MIN = 89233;
final double RANGE2_MAX = 923182;
double userPassword;
String inputString;
int tryNumber = 0;
inputString= JOptionPane.showInputDialog("Hello there, whats your password?");
userPassword = Integer.parseInt(inputString);
tryNumber ++;
while(!(userPassword >=RANGE1_MIN && userPassword < RANGE1_MAX||userPassword > RANGE2_MIN && userPassword <=RANGE2_MAX)){
System.out.println("Your password is wrong please try again !!!");
System.out.println("how many times tried:" +tryNumber);
inputString= JOptionPane.showInputDialog("Please re-enter passwoerd");
userPassword = Integer.parseInt(inputString);
tryNumber++;
}
System.out.println("WELCOME");
//Optional
System.out.println("how many times tried:" +tryNumber);
}
}