I am trying to write a program for my school-based assignment. It is supposed to accept names as string
s, and a salary input as an integer
, and tell you whether you are illegible or able to participate in party sections, and repeats until stop=9
.
Everything went well, but the issue is the string
variables accept erroneous names as inputs and continue. For example 'John32@#$^^'
.
I want the program to not accept these inputs, and write a line stating that it will not continue with any name with anything other than characters. This should also not add a number to stop. The source code is below.
program Sba;
Uses
Windows;
var
FName,LName:String;
Stop,Salary:Integer;
//procedure Sleep(milliseconds: Cardinal); stdcall; external 'kernel32.dll'; //Added sleep as a procedure for delay
Begin
Repeat //Repeats until stop = 9
Writeln('Hi User,please Enter your First Name'); //Prompting user to enter their First initials
Readln(FName); //Attaches the string entered to the variable FName
Sleep(1000);//Delay 1second
Writeln('First Name entered'); //Lets the user know they have entered their first initials
Sleep(1000);
Writeln('Please Enter your Last name'); //Prompting user to enter their last initial
Readln(LName); //Attaches the string entered to the variable LName
Sleep(1000);
Writeln('Last Name entered'); //Lets the user know they have entered their last initials
Sleep(800);
Writeln('Hi ',' ',FName,' ',LName); //Writes Line Hi (First Name) (Last Name)
Sleep(1000);
Writeln('Please enter The amount you have paid');//Prompts user for their payment
Readln(Salary); //Atttached value entered to Salary
Writeln('Reading your payment will be done in four seconds');
Sleep(4000);//delay 4 seconds
Writeln('Done!');
If (Salary<1000) Then
Begin
Writeln('You do not have sufficient funds to play in a section');
Sleep(1000);
End;
Sleep(1000);
If (Salary>=1000) AND (Salary<=2000) then //Testing conditions
Begin
Sleep(1000);
Writeln('Congrats, You are eligible to play in the Tribe Section'); //Tells use what section they are available to play in
End;
If (Salary>=2100) AND (Salary<=3000) then //Testing conditions
Begin
Sleep(1000);
Writeln('Congrats, You are eligible to play in the Poison Section');
End;
If (Salary>=3100) AND (Salary<=5000) then //Testing conditions
Begin
Sleep(1000);
Writeln('Congrats, You are eligible to play in the Harts Section');
End;
Writeln('Press enter to continue');
Readln;
Writeln('Enjoy your day ' , FName,'!');
Stop:=Stop+1; //Repeats until stop= 9
Sleep(1000);
Until Stop=9;//Repeats this 10 times
Writeln('Written By Timothy Adams 4-1');
Readln;
end.