Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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.]
expand button
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.]
expand button
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
Check Mark
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;
}

Knowledge Booster
Background pattern image
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
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education