QuestionQuestion

Question 1: Validating a Password
The first thing that any online website needs is a password validation system. In this question, you will write a method that will check that a particular String is a secure password. Write a method public static boolean isSecurePassword(String password) in PasswordValidator.java that returns whether or not a password is a secure password.
A password is defined as secure if it satisfies the following conditions.
• Its length is at least 10.
• It has at least one capital letter
• It has at least one lower case letter
• It has at least one number
• Every character is an alphanumeric character (e.g. uppercase, lowercase, or a number.
There are no symbols such as a ; allowed)
This problem is a complicated to solve by itself because there are several different steps. This would be a perfect time to use auxiliary methods. These are methods that are not required but help you in the computation by letting you break your big problem into smaller problems.
For example, you could divide this problem into the smaller problems of
1. determining if the length is at least 10
2. determining if there is at least one capital letter
3. determining if there is at least one lower case letter
4. ...
If you are clever about the subtasks and auxiliary methods you write, you may be able to reuse the same method for multiple steps. If you add these auxiliary methods, you should define them as private static instead of what we’ve seen so far as public static. (Just write the word private instead of public in the method header.)
The above suggestion applies in particular if you are having trouble finding a bug. Dividing the problem into smaller tasks will make it easier to define “checkpoints” at which you can say “I know the problem is before this check point because the output from the method was incorrect” or “I know the problem is after this checkpoint because the output from the method was correct” You can determine whether it is before or after these points by using some cleverly chosen System.out.println() statements to print certain values and compare it with what you’d expect to get at each point.
To test you method as you write it, you are encouraged to write a main method. Your main method will not be graded, but you can call your method from the main method on various inputs and then print the results. You can then compare it to what you’d expect. For example, since ABCDEFGHIJK is not a valid password, if you call your method with ABCDEFGHIJK as input, it should return false. Nowhere in your code should you be using the Scanner class.

Question 2: Plagiarism Detection
Write a method compareStrings in PlagiarismDetector.java which takes as input two Strings and returns a boolean representing whether your program concludes that the two strings are very similar to each other. A boolean result of true indicates the Strings are very close to each other and false indicates otherwise. Your method should determine this is based on the following rule: If at least 90% of the words in the first String appear in the second String AND at least 90% of the words in the second String appear in the first String, your method should return true. Otherwise your method should return false. For the purpose of this assignment, a “word” is any sequence of characters other than newlines, tabs, spaces, and other “white space” characters. For example the String "abc d3; 33" is considered to have 3 words: abc, d3;, and 33. You should perform the check in a case sensitive fashion meaning that the words hello and HELLO will be treated as different words. Important hint: There is a library method defined on all Strings which allows you to produce a String[] based on a delimiter by splitting the String into several pieces. To split a String into several pieces based on “whitespace” (new lines, tabs, space, etc), you can call split in the following way. Assume the String you want to split is called foo. String[] pieces = foo.split("\\s");
For example, if foo contains the contents a bc def\nghi then writing foo.split("\\s") will produce a String[] with the contents a, bc, def, and ghi (remember that \n is the code for storing a new line in a char or String). Note that the double backslash is necessary (as opposed to just one backslash) because the method split is supposed to take as input a String of length 2, with the first character being a backslash. Since backslash denotes special characters, a backslash itself is a special character!
Here are a few examples along with the expected results:
• "a3 bb cc dd" vs "bb cc dd a3" yields True
• "aa bb cc" vs "aa aa aa" yields False because only 1 of 3 of the words from the second String are in the first
• "a b c d e f g h i j a a a a a a" vs "a b c d e f g h i k" yields True since at least 90 percent of the words from each String are included in the other.
• "a a a a a a a a a a a a b" vs "b b b b b b b b b b a" yields True because at least 90 percent of the words from each String are included in the other. Even though a appears multiple times in the first String the checker will only check that each at least 90 percent of the letters in one String occur in the other. The Strings "a" and "b" both appear in both Strings and so it is a match.
• "a a a a a a a a a b c" vs "a c" yields True since there are 11 words in the first String. The 9 as are all found in the second String, the b is not and the c is. So 10 11 of the words in the first String occur in the second. (The reverse match is trivially true since all words in the second String occur in the first.)
Note finally that you may make the following two assumptions: (That is, you do NOT need to handle these cases)
• Neither of the String variables passed as input will be null
• Neither Strings will have consecutive white space characters. That is, you do not need to handle cases with 2 spaces in a row for example.
To test you method as you write it, you are encouraged to write a main method. Your main method will not be graded, but you can call your method from the main method on various inputs and then print the results. Nowhere in your code should you be using the Scanner class.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class PasswordValidator {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
               
       String password = "sadfASkjh98";
       System.out.println("password: " + password);
       if (isSecurePassword(password)) {
            System.out.println("This password is valid ");
       } else {
            System.out.println("This password is invalid ");
       }
       System.out.println("");
       password = "AJSDGHJHGJGH";
       System.out.println("password: " + password);
       if (isSecurePassword(password)) {...
$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats