Created
November 26, 2016 12:31
-
-
Save JoeUnsung/d860d584b5468fcc42f84ddb84aa0185 to your computer and use it in GitHub Desktop.
Check password validation, if it has recurring character more than twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package joe; | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
class Check{ | |
static char temp1 = ' ', temp2 = ' ', temp3 = ' ', temp4 = ' '; | |
static String temp5 = " ", temp6 = " "; | |
public static String Check_pass(String passWord){ | |
for(int i = 0 ; i < passWord.length() - 3; i++){ | |
temp1 = passWord.charAt(i); | |
temp2 = passWord.charAt(i+1); | |
temp3 = passWord.charAt(i+2); | |
temp4 = passWord.charAt(i+3); | |
temp5 = passWord.substring(i,i+2); | |
//System.out.println(temp5); | |
temp6 = passWord.substring(i+2, i+4); | |
//System.out.println(temp6); | |
if (temp1 == temp2 || temp2 == temp3 || temp3 == temp4){ | |
return "reject"; | |
} | |
else if (temp5.equals(temp6)){ | |
return "reject"; | |
} | |
else { | |
continue; | |
} | |
} | |
return "accept"; | |
} | |
} | |
public class HW3_20101062_3 { | |
public static void main(String[] args){ | |
File file = new File("input3_5.txt"); | |
Scanner scin; | |
String[] passwords = null; | |
int count = 0; | |
if (file.exists()) { | |
try { | |
scin = new Scanner(file); | |
count = scin.nextInt(); | |
passwords = new String[count]; | |
for (int i=0; i<count; i++) { | |
passwords[i] = new String(scin.next()); | |
} | |
} catch (IOException e) {} | |
} | |
else { | |
System.out.println("input.txt not exist!!"); | |
} | |
for (int x = 0 ; x < count ; x++){ | |
System.out.println(passwords[x] + " : " +Check.Check_pass(passwords[x])); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment