Я новичок. В моей программе возникли такие ошибки:
[dcc32 Error] Project2.dpr(36): E2029 ';' expected but '.' found
[dcc32 Error] Project2.dpr(38): E2029 Declaration expected but end of file found
Вот программа, которую я написал:
program masquerader; //program name
Var //Declaring variables
Salary:integer; //Declared Salary as integer
procedure Sleep(milliseconds: Cardinal); stdcall;//Added sleep as a procedure for delay
Begin //Begins the program
Writeln('Enter Your Salary please user...'); //Outputs line Enter Your salary please user...
Readln(Salary); //Recieves the value and declares the integer value to salary
Writeln('Processing your input...'); //Outputs line to Let the user know its being processed
Sleep(4000); //4 second delay
Writeln('Done!');
If (Salary>=5000) AND (Salary<=8000) Then //Conditions are being test for the requirements for each section
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in poison'); //Outputs the section that matches the user's salary(5000-8000)
If (Salary>=3000) AND (Salary<=5000) Then //Conditions are being test for the requirements for each section
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in Blue devils');//Outputs the section that matches the user's salary(3000-5000)
If (Salary<3000) Then //Conditions are being test for the requirements for each section
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in The poor man section');//Outputs the section that matches the user's salary(x<=3000)
Writeln('Written by Timothy Adams');
Writeln('Fatima College 4-1');
Readln; //Declares the end of the read line
End. //End of program
ОТВЕТ:
Есть ряд проблем с вашим кодом.
Вы объявляете новую функцию Sleep(), не сообщая компилятору, где находится ее реализация. Таким образом, компилятор думает весь ваш код между begin и end является реализацией. Вот почему вы получаете ошибки, потому что вы завершаете реализацию функции end. вместо end;
Кроме того, блоки кода Delphi не определяются отступом, как вы предполагаете. Вам нужно использовать явные begin/ end операторы для группировки операторов вместе.
Попробуйте этот код:
program masquerader; //program name
uses
Windows;
Var //Declaring variables
Salary:integer; //Declared Salary as integer
//procedure Sleep(milliseconds: Cardinal); stdcall; external 'kernel32.dll'; //Added sleep as a procedure for delay
Begin //Begins the program
Writeln('Enter Your Salary please user...'); //Outputs line Enter Your salary please user...
Readln(Salary); //Recieves the value and declares the integer value to salary Writeln('Processing your input...'); //Outputs line to Let the user know its being processed
Sleep(4000); //4 second delay
Writeln('Done!');
If (Salary>=5000) AND (Salary<=8000) Then //Conditions are being test for the requirements for each section
Begin
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in poison'); //Outputs the section that matches the user's salary(5000-8000)
End;
If (Salary>=3000) AND (Salary<=5000) Then //Conditions are being test for the requirements for each section
Begin
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in Blue devils');//Outputs the section that matches the user's salary(3000-5000)
End;
If (Salary<3000) Then //Conditions are being test for the requirements for each section
Begin
Writeln('Thanks for your Input file should be ready in a second'); // Outputs this line to let the user know it is ready in a second
Writeln('Congratulations!,You are eligible to play in The poor man section');//Outputs the section that matches the user's salary(x<=3000)
End;
Writeln('Written by Timothy Adams');
Writeln('Fatima College 4-1');
Readln; //Declares the end of the read line
End. //End of program
Кстати, ваш код не обрабатывает Salary выше 8000.