Draw the appropriate control flow graph of the given pseudocode.Make sure to only use one number for blocks of code which are all sequential and
Draw the appropriate control flow graph of the given pseudocode.Make sure to only use one number for blocks of code which are all sequential and when the first line is executed, all of those lines are executed. Another tester has tried to number the code, but may not have done it correctly.
- Remember pseudocode is not focused on any particular language; it's only intended to give you an idea of what is done.
- While statement testing would be based upon a specific programming language, the purpose of this assignment is to make sure you understand how to manually trace through code to understand how to think about the code as well as statement coverage.
// count++ is a shorthand notation for count=count+1;
//prompt user for password
1. PRINT("Please enter a password: ");
String password=UserInput(); //user enters password
boolean isSixCharacters=false; //true if has 6 characters, false if doesn't
boolean hasOneUppercase=false; //true if has 1 uppercase character, false if doesn't
boolean hasOneLowercase=false; //true if has 1 lowercase character, false if doesn't
boolean hasOneDigit=false; //true if has 1 digit, false if doesn't
boolean hasSpecial=false; //true if special character, false if doesn't
int count=0;
2. while(count<3){
3. if(password.length()>8)
{
4. isSixCharacters=true;
}
else{
5. isSixCharacters=false;
}
6. char charValue;
int i=0;
7. while(i {
8. charValue=password.charAt(i);
9. if(Character.isUpperCase(charValue))
{
10. hasOneUppercase=true;
}
11. if (Character.isUpperCase(charValue))
{
12. hasOneLowercase=true;
}
13. else if (Character.isDigit(charValue))
{
14. hasOneDigit=true;
}
15. else if(charValue=='!' ||charValue=='#' || charValue=='@' || charValue=='%' || charValue=='(' ||charValue==')' || charValue=='!' || charValue=='$')
{
16. hasSpecial=true;
}
17. i++;
}
//Process complexity requirements
18. if(hasOneUppercase)
19. count++;
20. if(hasOneLowercase)
21. count++;
22. if(hasOneDigit)
23. count++;
24. else if(hasSpecial)
25. count++;
else
26. System.out.println("Error");
27. if(count<3){
28. count=0;
PRINT("Password does not meet requirements.");
PRINT("Please reenter a password: ");
password=UserInput(); //user enters password
}
}
Step by Step Solution
3.24 Rating (162 Votes )
There are 3 Steps involved in it
Step: 1 Unlock smart solutions to boost your understanding
the appropriate control flow graph CFG for the given pseudocode and explain the reasoning behind it Understanding the Code The provided code validates a userentered password against specific complexit...83% of Computer Science Students Improved their GPA!
Step: 2Unlock detailed examples and clear explanations to master concepts
Step: 3Unlock to practice, ask, and learn with real-world examples
See step-by-step solutions with expert insights and AI powered tools for academic success
- Access 30 Million+ textbook solutions.
- Ask unlimited questions from AI Tutors.
- 24/7 Expert guidance tailored to your subject.
- Order free textbooks.
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started