0% found this document useful (0 votes)
34 views5 pages

Flow Chart

The document describes an algorithm to validate a ticket number: 1. It prompts the user to enter a ticket number and checks that it is between 10-12 digits. 2. It removes the last digit, converts the number to an integer, divides it by 7, and calculates the remainder. 3. It checks if the remainder matches the last removed digit, and if so prints that the number is valid, otherwise it prints an error.

Uploaded by

Esmael Uta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

Flow Chart

The document describes an algorithm to validate a ticket number: 1. It prompts the user to enter a ticket number and checks that it is between 10-12 digits. 2. It removes the last digit, converts the number to an integer, divides it by 7, and calculates the remainder. 3. It checks if the remainder matches the last removed digit, and if so prints that the number is valid, otherwise it prints an error.

Uploaded by

Esmael Uta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

Algorithm
1. Start
2. Prompt the user to enter a ticket number
3. Read the ticket number from the user
4. Calculate the length of the ticket number
5. Check if the length of the ticket number is between 10 and 12
6. If the length of the ticket number is not between 10 and 12, then print an error message and go
to step 2
7. Drop the last digit of the ticket number
8. Convert the remaining ticket number to an integer
9. Divide the remaining ticket number by 7
10. Calculate the remainder of the division
11. Check if the remainder of the division is equal to the last digit of the ticket number
12. If the remainder of the division is not equal to the last digit of the ticket number, then print an
error message and go to step 2
13. Print a message indicating that the ticket number is valid
14. End
2. Pseudo-code

start
prompt the user to enter a ticket number
read the ticket number from the user
calculate the length of the ticket number
if the length of the ticket number is not between 10 and 12
print an error message
go to step 2
drop the last digit of the ticket number
convert the remaining ticket number to an integer
divide the remaining ticket number by 7
calculate the remainder of the division
if the remainder of the division is not equal to the last digit of the ticket number
print an error message
go to step 2
print a message indicating that the ticket number is valid
end
3. Flow chart
4. Hand-trace test results

Ticket number 1: 12344321566

Step 1: Prompt the user to enter a ticket number


Step 2: Read the ticket number from the user (12344321566)
Step 3: Calculate the length of the ticket number (11)
Step 4: Check if the length of the ticket number is between 10 and 12 (yes)
Step 5: Drop the last digit of the ticket number (1234432156)
Step 6: Convert the remaining ticket number to an integer (1234432156)
Step 7: Divide the remaining ticket number by 7 (176347450)
Step 8: Calculate the remainder of the division (6)
Step 9: Check if the remainder of the division is equal to the last digit of the ticket number (yes)
Step 10: Print a message indicating that the ticket number is valid

Ticket number 2: 23234545678

Step 1: Prompt the user to enter a ticket number


Step 2: Read the ticket number from the user (23234545678)
Step 3: Calculate the length of the ticket number (11)
Step 4: Check if the length of the ticket number is between 10 and 12 (yes)
Step 5: Drop the last digit of the ticket number (2323454567)
Step 6: Convert the remaining ticket number to an integer (2323454567)
Step 7: Divide the remaining ticket number by 7 (331922075)
Step 8: Calculate the remainder of the division (2)
Step 9: Check if the remainder of the division is equal to the last digit of the ticket number (no)
Step 10: Print an error message

You might also like