Question 1: Encryption Program (50 points) Have you checked the list of the most
ID: 3839444 • Letter: Q
Question
Question 1: Encryption Program (50 points) Have you checked the list of the most frequently-used passwords on internet? Then, you will not be surprised at the fact that password' and 'qwerty' are at the top. You, as a student of Comp202 would never use something so indiscreet (right?). But internet passwords are not the only passcodes that give access to very sensitive information. For example, the PIN number of your debit card gives you access to your bank account. This number is composed by just four digits. Then, there are only 10000 possible combinations to decipher your pin code (making a lot easier for a thief to guess at it). Even if there are several possible combinations, according to cyber-security analysis, 27% of debit card clients use the top 20 most common PIN numbers for ATM cards. More surprisingly (or depressingly) is the fact that the code 1234' is used by almost 11% of card holders. Your birthday should also be avoided as PIN because nearly all users carry documentation of it on their wallet. Statistical studies have shown that a competent thief is able to gain use of an ATM card once for every 11-18 stolen wallets. Users try to use memorable passwords because they will not forget about it. However, it makes the work of thieves easier. As a Comp202 student, you have been commissioned to write a java program which takes a memorable PIN number and encrypts it according to a set of instruction provided to you. The number produced at the end of the encryption process is the one that you will use as your new ATM PIN. INPUT The input to your program is a set of four integer numbers that represent the ATM PIN access code to encrypt ENCRYPTION The list of encryption steps is as follows 1. Take the input muumber and reverse it. 2. If the reversed number e., the number produced by step 1.) is greater or equal than 4987, then subtract the sum of its digits. Otherwise, add the sum of its digits 3. If the number produced by step 2 is even, then add the biggest digit. Otherwise, subtract the smallest digit. OUTPUT: For your input ATM PIN, encrypt the number with the instructions given, and output each of the en crypted steps performed on your number Lets see an example to make clear what your program must output SAMPLE INPUT 1: 1234Explanation / Answer
//find smallest
//code for number
int no=Integer.parseInt(args);
int revno=Integer.parseInt(reverse); //reverse of input integer
int sumOfDigits=digit1+digit2+digit3+digit4; //sum of digit
if(revno>4987){
revno=revno-sumOfDigits;
}
else{
revno=revno+sumOfDigits;
}
//find the biggest digit
int m=maxDigit(revno);
//find the smallest dgit
int n=minDigit(revno);
//add biggest or subtract smallest depending on condition
if(revno%2==0){
revno=revno+m;
}
else{
revno=revno-n;
}
//string form of revno
String res=String.valueOf(revno);
int len=res.length();
if(len==4)
System.out.println(res);
else if(len==3)
System.out.println("0"+res);
else if(len==2)
System.out.println("0"+res);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.