Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

These can be the same program, you can disregard them being separate. PART I Ima

ID: 3721645 • Letter: T

Question

These can be the same program, you can disregard them being separate.

PART I

Imagine you are developing a software package for Amazon.com that requires users to enter their own passwords. Your software requires that users’ passwords meet the following requirements:

The password should be at least 8 characters

The password should contain at least one uppercase and at least one lowercase letter

The password should contain at least one digit

The password may not contain a blank

Write a program that verifies that passwords are valid.

Read a series of passwords from an input file. Remove any leading or trailing blanks. For each password, determine if it is valid by calling a method to test for criteria above. The main method should print each password, and a message that it is valid or not valid. When it is done, print a message that the program is ending.

Your data should include at least 10 passwords, though your program doesn’t know how many there will be. Include 2-3 valid passwords, and at least one or two that are invalid for any one of the above criteria. Have some that are invalid for more than one criterion. Also, include leading blanks in some of the passwords, and remove them from the password.

PART II

Write a program that accepts as input a sentence in which all the words are run together, but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string “StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.” Also check if the sentence ends with a “.”(period). If it does not, add a period at the end of the sentence.

You should use a method to perform the editing to the sentence.

Print the original sentence and the converted version.

Repeat this for as many lines as there are in the input file. Use at least 8 lines of data. Have some with only one word. Have some words with only one letter. Some should end with a “.” and some not.

Explanation / Answer

import java.util.Scanner; // Needed for the Scanner class public class Chpt10Number05 { public static void main(String[] args) { // Create a Scanner object to read input. Scanner keyboard = new Scanner(System.in); String input; // To hold the input // Ask the user to enter their password System.out.print("Please enter your password: "); input = keyboard.nextLine(); // Demonstrate the method by passing it the inputted string. if (authenticate(input)) System.out.print("Thank you for entering your password."); else System.out.print("Error: This password is not valid."); System.out.println(); } /* Method: Accepts a String object (password) as an argument    and verifies whether it meets the criteria of a valid password. */ private static boolean authenticate(String password) { // The password should be at least six characters long. // The password should contain at least one uppercase // and at least one lowercase letter.    // The password should have at least one digit. return ( (password.length() == 6) && (password.matches("[A-Z]")) && (password.matches("[a-z]")) && (password.matches("[0-9]") )    ); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote