Epic Systems Interview Question
Developer Program EngineersCountry: United States
Hello Tony, could you please provide an example, the one you have provided is not very clear. what do you mean by 124 is acceptable if we actually have "126 46.." as key code?
In 1-9 keypad one key is not working. If someone enters a password then not working key will not be entered. You have given expected password and entered password. Check that entered password is valid
or not. Ex: entered 164, expected 18684 (you need to take care as when u enter 18684 and 164 only both will be taken as 164 input)
In 1-9 keypad one key is not working. If someone enters a password then not working key will not be entered. You have given expected password and entered password. Check that entered password is valid
or not. Ex: entered 164, expected 18684 (you need to take care as when u enter 18684 and 164 only both will be taken as 164 input)
public class PasscodeErrorAllow {
public static void main(String[] args)
{
String passcode="18283";
String given="123";
boolean matches=checkPasscode(passcode,given);
System.out.println(matches);
}
public static boolean checkPasscode(String passcode,String given)
{
if(removeAll(passcode,0).equals(given))
{ System.out.println("passcode:"+passcode+",given:"+given);
return true;
}
if(removeAll(passcode,1).equals(given)) return true;
if(removeAll(passcode,2).equals(given)) return true;
if(removeAll(passcode,3).equals(given)) return true;
if(removeAll(passcode,4).equals(given)) return true;
if(removeAll(passcode,5).equals(given)) return true;
if(removeAll(passcode,6).equals(given)) return true;
if(removeAll(passcode,7).equals(given)) return true;
if(removeAll(passcode,8).equals(given)) return true;
if(removeAll(passcode,9).equals(given)) return true;
return false;
}
public static String removeAll(String passcode,Integer no)
{
String result =passcode.replace(no.toString(), "");
return result;
}
}
public class faulty {
public static void main(String[] args)
{
String given_password = "164";
String exp_password = "18684";
boolean flag = false;
for(Character i='0'; i<='9'; i++)
{
String possible_password = exp_password.replaceAll(i.toString(),"");
if(possible_password.equalsIgnoreCase(given_password))
{
System.out.println("Password Accepted");
flag = true;
break;
}
}
if(flag==false)
{
System.out.println("Password is incorrect");
}
}
}
import java.util.Scanner;
public class OnekeyNotWorking {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String number = in.next();
String notWorking = in.next();
String userEntered = in.next();
String newNumber = number.replace(notWorking,"");
System.out.println(newNumber);
if(newNumber.equals(userEntered)) {
System.out.println("Password correct");
} else {
System.out.println("Wrong");
}
}
}
import java.util.Scanner;
public class OnekeyNotWorking {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String number = in.next();
String notWorking = in.next();
String userEntered = in.next();
String newNumber = number.replace(notWorking,"");
System.out.println(newNumber);
if(newNumber.equals(userEntered)) {
System.out.println("Password correct");
} else {
System.out.println("Wrong");
}
}
}
- Anonymous June 04, 2015