The program should have a main method and another method called passwordChecker. The main method will send the two new passwords to passwordChecker.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

//Assignment 06 
*/
public static void main[](String[] args) {
    
    String pass= "ICS 111";
    System.out.printIn(valPassword(pass));
}

      /*

 

public static boolean valPassword(String password)
{
    if(password.length() > 6)
    {
        if(checkPass(password)
        {
            return true;
        }
        else
        {
            return false; 
        }
      
}
else
       System.out.print("Too small");
    return false;
}

public static boolean checkPass (String password)
{
    boolean hasNum=false; boolean hasCap = false; boolean hasLow = false; char c;
    for(int i = 0; i < password.length(); i++)
    {
        c = password.charAt(1);
        if(Character.isDigit(c));
        {
            hasNum = true;
        }
        else if(Character.isUpperCase(c))
        {
            hasCap = true;
        }
        else if(Character.isLowerCase(c))
        {
            hasLow = true;
        }
    }      return true;
    {
        return false;
    }

 

 


    
}

Type your current password: ICS111
Type a new password: Secret Password!
Retype the new password: Secret Password!
Your new password can not have spaces.
Your password was not changed.
Type your current password: ICS111
Type a new password: SecretPassword
Retype the new password: SecretPassword
Your new password must contain ! or $ or ?.
Your password was not changed.
The program should have a main method and another method called passwordChecker.
The main method will send the two new passwords to passwordChecker.
The main method of the program will:
1. Print "Type your current password:" and accept user input.
2. Check the user input against a current password (test against the string "ICS111").
a. If the user input does not match the current password, print "Password not
recognized." and end.
b. If the user input does match the current password, continue to the next
step.
3. Print "Type a new password:" and accept user input.
4. Print "Retype the new password:" and accept user input.
5. Send the two new passwords to a boolean method named passwordChecker.
a. If passwordChecker returns true, print "Your password was changed to: "
followed by the new password.
b. If passwordChecker returns false, print "Your password was not changed."
6. End of program.
The passwordChecker method will:
1. Receive the two versions of a new password.
2. Set a boolean return value to false.
3. Compare the two passwords to be sure they match.
Transcribed Image Text:Type your current password: ICS111 Type a new password: Secret Password! Retype the new password: Secret Password! Your new password can not have spaces. Your password was not changed. Type your current password: ICS111 Type a new password: SecretPassword Retype the new password: SecretPassword Your new password must contain ! or $ or ?. Your password was not changed. The program should have a main method and another method called passwordChecker. The main method will send the two new passwords to passwordChecker. The main method of the program will: 1. Print "Type your current password:" and accept user input. 2. Check the user input against a current password (test against the string "ICS111"). a. If the user input does not match the current password, print "Password not recognized." and end. b. If the user input does match the current password, continue to the next step. 3. Print "Type a new password:" and accept user input. 4. Print "Retype the new password:" and accept user input. 5. Send the two new passwords to a boolean method named passwordChecker. a. If passwordChecker returns true, print "Your password was changed to: " followed by the new password. b. If passwordChecker returns false, print "Your password was not changed." 6. End of program. The passwordChecker method will: 1. Receive the two versions of a new password. 2. Set a boolean return value to false. 3. Compare the two passwords to be sure they match.
Type your current password: ICS111
Type a new password: SecretPassword!
Retype the new password: SecretPassword!
Your password was changed to: SecretPassword!
In order for the password to be changed:
a. the two new passwords must match
b. The new password must have 6 or more characters
c. The new password must contain no spaces
d. The new password must contain at least one of the following characters: ! or $ or
?
If the new password is acceptable, then the program will say that is has changed
the password. If any of the rules are violated, the program will tell the user what's wrong
and not change the password.
Here are examples of several unsuccessful runs: (user input is in bold):
Type your current password: ICS141
Password not recognized.
Your password was not changed.
Type your current password: ICS111
Type a new password: shhh
Retype the new password: shhh
Your new password must contain 6 or more characters.
Your password was not changed.
Transcribed Image Text:Type your current password: ICS111 Type a new password: SecretPassword! Retype the new password: SecretPassword! Your password was changed to: SecretPassword! In order for the password to be changed: a. the two new passwords must match b. The new password must have 6 or more characters c. The new password must contain no spaces d. The new password must contain at least one of the following characters: ! or $ or ? If the new password is acceptable, then the program will say that is has changed the password. If any of the rules are violated, the program will tell the user what's wrong and not change the password. Here are examples of several unsuccessful runs: (user input is in bold): Type your current password: ICS141 Password not recognized. Your password was not changed. Type your current password: ICS111 Type a new password: shhh Retype the new password: shhh Your new password must contain 6 or more characters. Your password was not changed.
Expert Solution
Step 1

This is very simple.

Here is the complete and correct Java code for the given problem.

Note: The errors are indentation and syntax errors.

--------------------------------------------- Java Code -------------------------------------------------

public class printPassword{
    public static void main(String args[]){
        String pass= "ICS 111";
        System.out.println(valPassword(pass));
    }
}

public class valPassword{
    public static boolean valPassword(String password){
        if(password.length() > 6){
            if(checkPass(password)){
                return true;
            }
            else
            {
                return false; 
            }
        }
        else{
            System.out.println("Too small");
            return false;
            
        }
    }

public static boolean checkPass (String password){
    boolean hasNum=false; boolean hasCap = false; 
    boolean hasLow = false; char c;
    
    for(int i = 0; i < password.length(); i++){
        c = password.charAt(1);
        if(Character.isDigit(c)){
            hasNum = true;
        }
        else if(Character.isUpperCase(c)){
            hasCap = true;
        }
        else if(Character.isLowerCase(c)){
            hasLow = true;
        }
        
    }   return true;
    return false;
}

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education