using System; using System.Drawing; using System.Xml.Linq; internal class Program { // This program will allow users to input their names, age and national insurance number, including // validation and length checks, declared variables as well as an output from the system. // The program will display the correct information back to the user. private static void Main(string[] args) { //declared variables string Firstname; //variable delcaring the first name string Surname; // variable delcaring the surname string NationalInsuranceNumber; //variable declaring the national insurance number int Age; //variable declaring the age //Firstname input, with presence check Console.WriteLine("Please enter your first name."); Firstname = Console.ReadLine(); do { if (Firstname.Length == 0) { Console.WriteLine("Error! Please re enter your First name."); Firstname = Console.ReadLine(); } } while (Firstname.Length == 0); Console.WriteLine(" "); Console.WriteLine("Your First Name is " + Firstname); Console.ReadLine(); //Surname input, with presence check Console.WriteLine("Please enter your surname."); Surname = Console.ReadLine(); do { if (Surname.Length == 0) { Console.WriteLine("Error! Please re enter your Surname."); Surname = Console.ReadLine(); } } while (Surname.Length == 0); Console.WriteLine(" "); Console.WriteLine("Your surname is " + Surname); Console.ReadLine(); //National Insurance number input, with presence check Console.WriteLine("Please enter your National insurance number"); NationalInsuranceNumber = Console.ReadLine(); do { if (NationalInsuranceNumber.Length < 13) { Console.WriteLine("Error! Please re enter your national insurance number (e.g. PE 25 34 12 B)"); NationalInsuranceNumber = Console.ReadLine(); } } while (NationalInsuranceNumber.Length > 13); { Console.WriteLine(" "); Console.WriteLine("Your national insurance number is " + NationalInsuranceNumber); NationalInsuranceNumber = Console.ReadLine(); } //Age input, with length check Console.WriteLine("Please enter your age."); Age = Convert.ToInt32(Console.ReadLine()); do { if (Age < 16) { Console.WriteLine("Error! Please re enter your age (16 or above)"); } } while (Age > 15); //user input display Console.WriteLine(" "); Console.WriteLine("Your Firstname is " + Firstname); Console.WriteLine("Your Surname is " + Surname); Console.WriteLine("Your National Insurance Number is " + NationalInsuranceNumber); Console.WriteLine("Your age is " + Age); Console.WriteLine("Please press enter to exit"); Console.ReadKey(); } }