Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 4150 Name question1 Date/Time 16-Jul-2019 01:32:09 PM

Copy text from below
import java.util.Scanner;

public class Exercise11 {

public static final int PASSWORD_LENGTH = 8;

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
System.out.print(
"1. A password must have at least eight characters.\n" +
"2. A password consists of only letters and digits.\n" +
"3. A password must contain at least two digits \n" +
"Input a password (You are agreeing to the above Terms and Conditions.): ");
String s = input.nextLine();

if (is_Valid_Password(s)) {
System.out.println("Password is valid: " + s);
} else {
System.out.println("Not a valid password: " + s);
}

}

public static boolean is_Valid_Password(String password) {

if (password.length() < PASSWORD_LENGTH) return false;

int charCount = 0;
int numCount = 0;
for (int i = 0; i < password.length(); i++) {

char ch = password.charAt(i);

if (is_Numeric(ch)) numCount++;
else if (is_Letter(ch)) charCount++;
else return false;
}


return (charCount >= 2 && numCount >= 2);
}

public static boolean is_Letter(char ch) {
ch = Character.toUpperCase(ch);
return (ch >= 'A' && ch <= 'Z');
}


public static boolean is_Numeric(char ch) {

return (ch >= '0' && ch <= '9');
}

}




comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
4400 GymRepairPro 28-Sep-2020 03:41:03 AM
4399 Jeux video M 26-Sep-2020 03:11:39 PM
4398 port 24-Sep-2020 08:03:56 AM
4397 iptable 24-Sep-2020 07:42:29 AM
4396 Massage Hut 20-Sep-2020 10:46:07 AM
4395 nd 18-Sep-2020 02:57:19 PM
4394 aa 18-Sep-2020 12:31:35 PM
4393 Ss 15-Sep-2020 09:18:37 AM
4392 Gg 15-Sep-2020 09:12:15 AM
4391 Link 15-Sep-2020 09:07:28 AM
4390 Locksmithlan 13-Sep-2020 05:26:28 PM
4389 osman 27-Aug-2020 09:08:34 PM
4388 osm 27-Aug-2020 09:06:56 PM
4387 copy 24-Aug-2020 08:04:26 PM
4386 fdgdfhdfhdfd 19-Aug-2020 08:12:18 PM
4385 aa 05-Aug-2020 12:08:51 AM
4384 nvcx 03-Aug-2020 06:46:25 PM
4383 lll 03-Aug-2020 06:45:54 PM
4382 Abd 07-Jul-2020 01:39:30 AM
4381 Dds 22-Jun-2020 11:52:09 AM
4380 Shahbaz bin 16-Jun-2020 08:33:52 AM
4379 Shahbaz bin 14-Jun-2020 09:43:02 AM
4378 meet 31-May-2020 02:01:24 PM
4377 Bills 20-May-2020 04:26:40 PM
4376 xk 18-May-2020 12:17:09 AM
4375 jamshed 12-May-2020 04:32:56 PM
4374 Saad 07-May-2020 11:58:32 PM
4373 Furqan 06-May-2020 06:13:59 PM
4372 Cyanide 06-May-2020 01:41:09 PM
4371 setprecison 03-May-2020 05:50:29 PM

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 [Next] [Last]
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com