Exercise 1 [10 points]: Write a static method named numUnique that accepts an array of integers as a parameter and returns the number of unique values in that array. The array may contain positive integers in no particular order, which means that the duplicates will not be grouped together. For example, if a variable called list stores the following values: int[] list = {7, 5, 22, 7, 23, 9, 1, 5, 2, 35, 6, 11, 12, 7, 9}; then the call of numUnique(list) should return 11 because this list has 11 unique values (1, 2, 5, 6, 7, 9, 11, 12, 22, 23, and 35). It is possible that the list might not have any duplicates. For example if the list contain this sequence of values: int[] list = {1, 2, 11, 17, 19, 20, 23, 24, 25, 26, 31, 34, 37, 40, 41}; Then a call to the method would return 15 because this list contains 15 different values. If passed an empty list, your method should return 0. Note: It might be beneficial to sort the array before you count the unique elements. To sort an integer array, you can use Arrays.sort() method. Exercise 2 [10 points]: In this exercise, you need to complete the following static methods and then use them. public class Password{ public static boolean passwordValidator(String pass1, String pass2){ // Your code goes here… } public static String passwordGenerator(int length){ // Your code goes here } } • The method passwordValidator takes two alpha-numeric passwords and returns true only if all the following conditions are met: i) Length of the password must be between 8 and 32 characters. ii) Password should contain at least one upper case and one lower case alphabet. iii)  Password should contain at least two numbers . iv) Password should contain at least one special character from this list {!, ~, _, %, $, #} . v) Both the password strings must match. • The method passwordGenerator – generates and returns a random password that satisfy the above-mentioned criteria with a specified length. • Now, write a PasswordTester class – in which you should test these static methods. Here is an example test run: Enter a new password: test123 Re-enter the same password: test123 Password should contain at least 8 characters. Enter a new password: qwerty123 Re-enter the same password: qwerty123 Password must contain at least 1 capital letter character. Enter a new password: qwerTy123 Re-enter the same password: qwerTy123 Password must contain at least 1 special symbol. Enter a new password: qwerTy_1 Re-enter the same password: qwerTy_1 Password must contain at least 2 numbers. Enter a new password: qwerTy_12 Re-enter the same password: qwerty_12 Both passwords must match. Enter a new password: qwerTy_12 Re-enter the same password: qwerTy_12 Success! The test cases shown above are sample only. When you test your code, you should test it for all possible cases. If the user cannot select a valid password within 7 tries, then your program should suggest four random passwords ( with different length ) to the user that satisfies all rules for the password . Take snapshots of different test runs for your program and attach those snapshots during submission. Exercise 3 [10 Points]: DateUtil: Complete the following methods in a class called DateUtil: • boolean isLeapYear(int year): returns true if the given year is a leap year. A year is a leap year if it is divisible by 4 but not by 100, or it is divisible by 400. • boolean isValidDate(int year, int month, int day): returns true if the given year, month and day constitute a given date. Assume that year is between 1 and 9999, month is between 1 (Jan) to 12 (Dec) and day shall be between 1 and 28|29|30|31 depending on the month and whether it is a leap year. • int getDayOfWeek(int year, int month, int day): returns the day of the week, where 0 for SUN, 1 for MON, …, 6 for SAT, for the given date. Assume that the date is valid. • String toString(int year, int month, int day): prints the given date in the format “xxxday d mmm yyyy”, e.g., “Tuesday 14 Feb 2012”. Ass…

Looking for solution of this Assignment?

WHY CHOOSE US?

We deliver quality original papers

Our experts write quality original papers using academic databases.We dont use AI in our work. We refund your money if AI is detected  

Free revisions

We offer our clients multiple free revisions just to ensure you get what you want.

Discounted prices

All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount

100% originality

We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity.We have ZERO TOLERANCE TO USE OF AI

On-time delivery

We will deliver your paper on time even on short notice or  short deadline, overnight essay or even an urgent essay