1) Identify the validation checks that you could use for the following inputs and justify your choice:
If more than a single validation check would be required from your perspective, please indicate which ones and why.
1a) Entering a telephone number.
1b) Entering a student's name.
1c) Entering a part number in this format: XXX999, where X must be any letter from the standard western alphabet (A-Z), and 9 must be replaced with a single digit between 0 and 9.
2) Write an algorithm using pseudocode to check the age and height of a child who wants to go on a fairground ride. The child's age must exceed 7, but below 12, their height must exceed 110 cm, but below 150 cm.
3) Write an algorithm using pseudocode to verify that a password's length exceeds 8 characters, but is shorter than 12 characters. (INCLUSIVE 8-12)
Here is program:
static void Main(string[] args)
{
//1)
string telephonenum;
string studentname;
string num;
Console.WriteLine("Enter telephone number: ");
telephonenum = Console.ReadLine();
Console.WriteLine("Enter student name: ");
studentname = Console.ReadLine();
Console.WriteLine("Enter part number: ");
num = Console.ReadLine();
//2)
int age;
int height;
Console.WriteLine("Enter age: ");
age = int.Parse(Console.ReadLine());
Console.WriteLine("Enter height: ");
height = int.Parse(Console.ReadLine());
if(age > 7 && age < 12 && height > 110 && height < 150)
{
Console.WriteLine("Accept");
}
else
{
Console.WriteLine("No accept");
}
}
Comments
Leave a comment