Test log
Stage 1: String longer than 6 characters | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT | FIELD5 |
---|---|---|---|---|
abcde | Invalid input. Try again. | Invalid input. Try again. | ||
abcdefg | Pass | Pass | ||
123456 | Invalid input. Try again. | Invalid input. Try again. | ||
1234567 | Pass | Pass | ||
Invalid input. Try again. | Invalid input. Try again. | |||
Stage 2: String containing lowercase ‘a’ | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT | |
ABCDEFG | Invalid input. Try again. | Invalid input. Try again. | ||
aBCDEFG | Pass | Pass | ||
AbCdEfG | Invalid input. Try again. | Invalid input. Try again. | ||
abCdEfGa | Pass | Pass | ||
aaaaaaaaaaaaaa | Pass | Pass | ||
bbbbbbaaaaaaa | Pass | Pass | ||
ccccccccccca | Pass | Pass | ||
ddddddddddda | Pass | Pass | ||
eeeeeeeeeeea | Pass | Pass | ||
fffffffffza | Invalid input. Try again. | Invalid input. Try again. | ||
Stage 3: String between 5-15 characters (no ‘z’) | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT | |
ab | Invalid input. Try again. | Invalid input. Try again. | ||
abcdefghijklmnopqr | Invalid input. Try again. | Invalid input. Try again. | ||
abcdez | Invalid input. Try again. | Invalid input. Try again. | ||
abcdefghij | Pass | Pass | ||
123456789012345 | Invalid input. Try again. | Invalid input. Try again. | ||
12345678901234 | Pass | Pass | ||
Stage 4: Integer between 5 and 500 | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT | |
3 | Invalid input. Try again. | Invalid input. Try again. | ||
501 | Invalid input. Try again. | Invalid input. Try again. | ||
123 | Pass | Pass | ||
1 | Invalid input. Please enter an integer. | Invalid input. Please enter an integer. | ||
abc | Invalid input. Please enter an integer. | Invalid input. Please enter an integer. | ||
500.5 | Invalid input. Please enter an integer. | Invalid input. Please enter an integer. | ||
Stage 5: Negative Integer | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT | |
5 | Invalid input. Try again. | Invalid input. Try again. | ||
-123 | Pass | Pass | ||
-5.5 | Invalid input. Please enter an integer. | Invalid input. Please enter an integer. | ||
Stage 6: Positive | Odd Integer | INPUT DATA | EXPECTED OUTPUT | GENERATED OUTPUT |
-7 | Invalid input. Try again. | Invalid input. Try again. | ||
10 | Invalid input. Try again. | Invalid input. Try again. | ||
25 | Pass | Pass | ||
5a | Invalid input. Please enter an integer. | Invalid input. Please enter an integer. |
Flow Chart
graph LR
subgraph Data Validation Program
Start((Start)) --> Stage1["Stage 1"]
Stage1 --> Validation1{Validate String Length > 6}
Validation1 --> |Invalid| Stage1
Validation1 --> |Valid| Stage2["Stage 2"]
Stage2 --> Validation2{Validate Contains Lowercase 'a'}
Validation2 --> |Invalid| Stage2
Validation2 --> |Valid| Stage3["Stage 3"]
Stage3 --> Validation3{Validate Length 5-15 & No 'z'}
Validation3 --> |Invalid| Stage3
Validation3 --> |Valid| Stage4["Stage 4"]
Stage4 --> Validation4{Validate Integer 5-500}
Validation4 --> |Invalid| Stage4
Validation4 --> |Valid| Stage5["Stage 5"]
Stage5 --> Validation5{Validate Negative Integer}
Validation5 --> |Invalid| Stage5
Validation5 --> |Valid| Stage6["Stage 6"]
Stage6 --> Validation6{Validate Positive Odd Integer}
Validation6 --> |Invalid| Stage6
Validation6 --> |Valid| AllStagesSuccessful{All Stages Successful?}
AllStagesSuccessful --> |No| Stage1
AllStagesSuccessful --> |Yes| Congratulations["Congratulations!"]
Congratulations --> End((End))
end
Top down design
Data Validation Program - Top-Down Design
Overall Purpose:
- Repeatedly prompt the user for input until all six validation stages are successfully completed.
- Each stage has a unique validation requirement.
Input:
- Stage 1: String (from user)
- Stage 2: String (from user)
- Stage 3: String (from user)
- Stage 4: Integer (from user)
- Stage 5: Integer (from user)
- Stage 6: Integer (from user)
Processing:
-
Main Function:
- Initializes success flags for each stage (all set to
false
initially). - Enters a loop that continues until all stages are successful.
- Within the loop, calls each stage function if it has not been successfully completed yet.
- Initializes success flags for each stage (all set to
-
Stage Functions (stage1, stage2, …, stage6):
- Prompt: Displays a message instructing the user on the type of input required.
- Read Input: Uses a
Scanner
to read the user’s input. - Validate: Performs specific checks on the input:
- Stage 1: Checks if the string length is greater than 6 characters.
- Stage 2: Checks if the string (converted to lowercase) contains the letter ‘a’.
- Stage 3: Checks if the string length is between 5 and 15 characters and does not contain the letter ‘z’.
- Stage 4: Checks if the integer is between 5 and 500 (inclusive).
- Stage 5: Checks if the integer is negative.
- Stage 6: Checks if the integer is positive and odd.
- Handle Invalid Input: If the input is invalid, displays an error message and continues to the next iteration of the loop within that stage.
- Return Value:
- If the input is valid, returns
true
to indicate success. - If the input is invalid, returns
false
.
- If the input is valid, returns
Output:
- Error Messages:
- For each stage, if the input is invalid, an appropriate error message is displayed.
- Success Message:
- Once all stages have been successfully completed, a congratulatory message is printed: “Congratulations! You have successfully completed all stages.”