0% found this document useful (0 votes)
8 views3 pages

User Input Validation Algorithm

The document outlines an algorithm for collecting and validating user information, including name, surname, age, height, and weight. Each input is validated through loops that check for specific character types, raising a `TypeError` and displaying an error message if the input is invalid. The process continues until valid input is received for each data point.

Uploaded by

jahanvi.mailme
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)
8 views3 pages

User Input Validation Algorithm

The document outlines an algorithm for collecting and validating user information, including name, surname, age, height, and weight. Each input is validated through loops that check for specific character types, raising a `TypeError` and displaying an error message if the input is invalid. The process continues until valid input is received for each data point.

Uploaded by

jahanvi.mailme
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

Algorithm to Collect and Validate User Information

1. Initialize Loop to Get Name:

- Repeat the following steps until valid input is obtained:

- Prompt the user to "Enter your name".

- If the input consists only of alphabetic characters:

- Exit the loop.

- Otherwise:

- Raise a `TypeError`.

- Display the error message: "Invalid Input. Please enter a string."

2. Initialize Loop to Get Surname:

- Repeat the following steps until valid input is obtained:

- Prompt the user to "Enter your surname".

- If the input consists only of alphabetic characters:

- Exit the loop.

- Otherwise:

- Raise a `TypeError`.

- Display the error message: "Invalid. Please enter a string."

3. Initialize Loop to Get Age:

- Repeat the following steps until valid input is obtained:

- Prompt the user to "Enter your age".

- If the input consists only of numeric characters:

- Exit the loop.


- Otherwise:

- Raise a `TypeError`.

- Display the error message: "Invalid Input. Please enter an Integer."

4. Initialize Loop to Get Height:

- Repeat the following steps until valid input is obtained:

- Prompt the user to "Enter your height".

- If the input is entirely numeric:

- Raise a `TypeError` and display the message "Invalid Input. Please enter a
float(decimal) value."

- If the input contains alphabetic characters:

- Raise a `TypeError` and display the message "Invalid Input. Please enter a
float(decimal) value."

- Otherwise:

- Exit the loop.

5. Initialize Loop to Get Weight:

- Repeat the following steps until valid input is obtained:

- Prompt the user to "Enter your weight".

- If the input consists only of alphabetic characters:

- Raise a `TypeError` and display the message "Invalid Input. Please enter a
float(decimal) value."

- If the input is entirely numeric:

- Raise a `TypeError` and display the message "Invalid Input. Please enter a
float(decimal) value."

- Otherwise:

- Exit the loop.


6. End of Algorithm.

You might also like