Fatal syntax error expected but identifier write found

135 / 22 hclroh~1.pas Fatal: Syntax error, ; expected but identifier WRITELN

Actually, the code contains more errors than what we guess. On my quick inspection I found it uses same name as the index for multiple level for-do loopings. Testing to compile the code, I got 6 compile time errors. See the image below.

And here is the code after put in to the code tag:

  1. Program HCL (input,output);

  2. CONST

  3. Max=45;

  4. Positive=‘Qualified’;

  5. Negative=‘Not Qualified’;

  6. QualifyClark=10000;

  7. QualifyBGarden=7500;

  8. QualifySkyfall=5500;

  9. BTime=3;

  10. ZERO=0;

  11. BRate=10/100;

  12. CCTime=3/2;

  13. CCRate=15/100;

  14. CUTime=3;

  15. DependentAllowance=75;

  16. Half=1/2;

  17. CORRECT=‘Approved’;

  18. WRONG=‘Not Approved’;

  19. TYPE

  20. StringArray=ARRAY[1..Max] OF String;

  21. RealArray=ARRAY[1..Max] OF Real;

  22. IntegerArray=ARRAY[1..Max] OF Integer;

  23. VAR

  24. ApplicantName:StringArray;

  25. HousingCommunity:StringArray;

  26. ApplicantGrossSalary:RealArray;

  27. ApplicantSalaryDeductions:RealArray;

  28. ApplicantSpouse:StringArray;

  29. SpouseGrossSalary:RealArray;

  30. SpouseSalaryDeductions:RealArray;

  31. ApplicationStatus:StringArray;

  32. FinalApplicationStatus:StringArray;

  33. NetSalaries:RealArray;

  34. ApplicantExpenses:RealArray;

  35. ApplicantRepayments:RealArray;

  36. Applicant:Integer;

  37. Name:String;

  38. Housing:String;

  39. GSalary:Real;

  40. Deductions:Real;

  41. Spouse:String;

  42. SpouseSalary:Real;

  43. SpouseDeductions:Real;

  44. TotalGrossSalary:Real;

  45. TotalSalaryDeductions:Real;

  46. NetSalary:Real;

  47. HalfNetSalary:Real;

  48. Balance:Real;

  49. Groceries:Real;

  50. Water:Real;

  51. Telephone:Real;

  52. Electricity:Real;

  53. Transport:Real;

  54. Dependents:Integer;

  55. Miscellaneous:Real;

  56. CCBalance:Real;

  57. CCInterest:Real;

  58. TotalCCAmount:Real;

  59. CCMonthlyPayments:Real;

  60. BPrinciple:Real;

  61. BLoanInterest:Real;

  62. TotalBLoanAmount:Real;

  63. BMonthlyPayments:Real;

  64. CUPrinciple:Real;

  65. CUInterest:Real;

  66. TotalCULoanAmt:Real;

  67. CUMonthlyPayments:Real;

  68. TotalMonthlyRepayments:Real;

  69. Sum:Integer;

  70. BEGIN{MAIN}

  71. FOR Applicant:=1 TO Max DO

  72. BEGIN{FOR}

  73.            ApplicantName[Applicant]:=»;

  74.            HousingCommunity[Applicant]:=»;

  75.            ApplicantGrossSalary[Applicant]:=0;

  76.            ApplicantSalaryDeductions[Applicant]:=0;

  77.            ApplicantSpouse[Applicant]:=»;

  78.            SpouseGrossSalary[Applicant]:=0;

  79.            SpouseSalaryDeductions[Applicant]:=0;

  80.            ApplicationStatus[Applicant]:=»;

  81.            FinalApplicationStatus[Applicant]:=»;

  82.            NetSalaries[Applicant]:=0;

  83.            ApplicantExpenses[Applicant]:=0;

  84.            ApplicantRepayments[Applicant]:=0;

  85. FOR Applicant:=1 TO Max DO

  86. BEGIN{FOR}

  87. Write(‘What is the name of the applicant?’);

  88. Readln(Name);

  89.            ApplicantName[Applicant]:=Name;

  90. Write(‘For which of the following housing communities are applications being made: «ClarkVillas», «BrentwoodGardens» or «SkyfallCourts»?’);

  91. Readln(Housing);

  92.            HousingCommunity[Applicant]:=Housing;

  93. Write(‘What is the applicants gross salary?’);

  94. Readln(GSalary);

  95.            ApplicantGrossSalary[Applicant]:=GSalary;

  96. Write(‘What are the applicants salary deductions?’);

  97. Readln(Deductions);

  98.            ApplicantSalaryDeductions[Applicant]:=Deductions;

  99. Write(‘Does the applicant have a spouse?’);

  100. Readln(Spouse);

  101.            ApplicantSpouse[Applicant]:=Spouse;

  102. IF Spouse=‘Yes’ THEN

  103. BEGIN{IF}

  104. Write(‘What is the spouses gross salary?’);

  105. Readln(SpouseSalary);

  106.                 SpouseGrossSalary[Applicant]:=SpouseSalary;

  107. Write(‘What are the spouses salary deductions?’);

  108. Readln(SpouseDeductions);

  109.                 SpouseSalaryDeductions[Applicant]:=SpouseDeductions;

  110. BEGIN{ELSE}

  111.                 SpouseSalary:=ZERO;

  112.                 SpouseGrossSalary[Applicant]:=SpouseSalary;

  113.                 SpouseDeductions:=ZERO;

  114.                 SpouseSalaryDeductions[Applicant]:=SpouseDeductions;

  115. FOR Applicant:=1 TO Max DO

  116. BEGIN{FOR}

  117.            TotalGrossSalary:=ApplicantGrossSalary[Applicant]+SpouseGrossSalary[Applicant];

  118.            TotalSalaryDeductions:=ApplicantSalaryDeductions[Applicant]+SpouseSalaryDeductions[Applicant];

  119.            NetSalary:= TotalGrossSalaryTotalSalaryDeductions;

  120.            NetSalaries[Applicant]:=NetSalary;

  121. FOR Applicant:=1 TO Max DO

  122. BEGIN{FOR}

  123. IF HousingCommunity[Applicant]=‘ClarkVillas’ THEN

  124. BEGIN{IF}

  125. IF NetSalaries[Applicant]>QualifyClark THEN

  126. BEGIN{IF}

  127. Writeln(‘Qualified’);

  128.                      ApplicationStatus[Applicant]:=Positive;

  129. Writeln(‘Not Qualified’);

  130.                      ApplicationStatus[Applicant]:=Negative;

  131. IF HousingCommunity =‘BrentWoodGardens’ THEN

  132. IF NetSalaries[Applicant]>QualifyBGarden THEN

  133. Writeln(‘Qualified’);

  134.                      ApplicationStatus[Applicant]:=Positive; THEN

  135. Writeln(‘Not Qualified’);

  136.                      ApplicationStatus[Applicant]:=Negative;

  137. IF HousingCommunity[Applicant]:=‘SkyfallCourts’ THEN

  138. IF NetSalaries[Applicant]>QualifySkyfall THEN

  139. Writeln(‘Qualified’);

  140.                      ApplicationStatus[Applicant]:=Positive; THEN

  141. Writeln(‘Not Qualified’);

  142.                      ApplicationStatus[Applicant]:=Negative;

  143. FOR Applicant:=1 TO Max DO

  144. IF ApplicationStatus[Applicant]:=Postive THEN

  145. Write(‘What is the principle loan Amount borrowed from the bank?’);

  146. Readln(BPrinciple);

  147. Write(‘What is the outstanding balance on the credit card?’);

  148. Readln(CCBalance);

  149. Write(‘What is the principle loan Amount borrowed from the credit union?’);

  150. Readln(CUPriniple);

  151.                 BLoanInterest:=(BPrinciple*BTime*BRate)/100;

  152.                 TotalBLoanAmt:=BLoanInterest+BPrinciple;

  153.                 BMonthlyPayments:=TotalBLoanAmt/36;

  154.                 CCInterest:=(CCBalance*CCTime*CCRate)/100;

  155.                 TotalCCAmt:=CCInterest+CCBalance;

  156.                 CCMonthlyPayents:=TotalCCAmt/18;

  157.                 CUInterest:=(CUPrinciple*CUTime*CURate)/100;

  158.                 TotalCULoanAmt:=CUInterest+CUPrinciple;

  159.                 CCMonthlyPayments:=TotalCULoanAmt/36;

  160.                 TotalMonthlyRepayments:= BMonthlyPayments + CCMonthlyPayments + CUMonthlyPayments;

  161.                 ApplicantRepayments[Applicant]:=TotalMonthlyRepayments;

  162. Write (‘How much money is spent on groceries?’);

  163. Readln (Groceries);

  164. Write (‘What is the value of the water bill?’);

  165. Readln (Water);

  166. Write (‘What is the value of the electricity bill?’);

  167. Readln (Electricity);

  168. Write (‘What is the value of the telephone bill?’);

  169. Readln (Telephone);

  170. Write (‘How much money is spent on transport’);

  171. Readln (Transport);

  172. Write (‘How many dependents does the applicant have?’);

  173. Readln (Dependents);

  174.                 Miscellaneous:= Dependents * DependentAllowance;

  175.                 TotalExpenses:= Groceries + Water + Telephone + Electricity + Transport + Miscellaneous;

  176.                 ApplicantExepenses:= TotalExpenses;

  177. FOR Applicant:=1 TO Max DO

  178. IF ApplicationStatus=Positive THEN

  179.                 HalfNetSalary:=NetSalaries[Applicant]*Half;

  180.                 Balance:=NetSalaries[Applicant] (ApplicantRepayments[Applicant] + ApplicantExpenses[Applicant]);

  181. IF Balance>HalfNetSalaries THEN

  182. Writeln (‘Approved’);

  183.                      FinalApplicationStatus[Applicant]:=CORRECT;

  184.                      Sum:= Sum + 1; ELSE

  185. Writeln(‘Not Approved’);

  186.                      FinalApplicationStatus[Applicant]:=WRONG;

  187. Writeln(‘THE DETAILS FOR THE APPLICATIONS MADE ARE AS FOLLOWS:’);

  188. Writeln (‘Application Details                 Applicant Information’);

  189. FOR Applicant:=1 TO Max DO

  190. Writeln (‘Name of Applicant:        ‘, ApplicantName[Applicant]:25);

  191. Writeln (‘Housing Community:        ‘, HousingCommunity[Applicant]:25);

  192. Writeln (‘Initial Application Status’, ApplicationStatus[Applicant]:25);

  193. Writeln (‘Final Application Status  ‘, FinalApplicationStatus[Applicant]:25);

  194. Writeln (‘A total of ‘, Sum,‘ applicants were approved for Housing.’);

  195. end;

  196. end;

  197. end;

  198. end;

  199. end;

  200. end;

  201. end;

  202. end;

  203. end;

  204. end;

  205. end;

  206. END.

It seems like a class homework and the TS only care about the urgency to finish it. Well, impatient is a big no for programming. >:D

Those bugs can be solved easily but I will let others who is willing to help impatient student to help.

Fatal syntax error expected but identifier writeln found

ProgramerForever
Дата 15.4.2010, 15:43 (ссылка) | (нет голосов) Загрузка .

Опытный

Профиль
Группа: Участник
Сообщений: 554
Регистрация: 15.11.2006
Где: Новосибирск

Репутация: нет
Всего: 5

Возникла проблема с Free Pascal. Не компилирует программы: ошибка » Fatal: Compilation aborted «.
Путь установки не менял, всё оставил по умолчанию. Версия компилятора — fpc-2.4.0.i386-win32.

Проблема решена: насколько я понял, *.pas файлы надо СОЗДАВАТЬ в программе, а не ОТКРЫВАТЬ их.

Вопрос в силе. Всё опять повторилось.

Вот, например, начал набрасывать программку:

Код
program kr4;
uses crt;

Const N=10;
var
a:array[1..N] of string;
i,l:integer;

l:=i-1;
for i:=1 to l
begin
writeln(a[i]);
end;
repeat until keypressed;
end.

Код
kr4.pas(12,3) Error: Illegal expression
kr4.pas(13,5) Fatal: Syntax error, «;» expected but «identifier WRITELN» found
kr4.pas(0) Fatal: Compilation aborted
Код
kr4.pas(0) Fatal: Compilation aborted

Это сообщение отредактировал(а) ProgramerForever — 15.4.2010, 21:16

Ozzя
Дата 26.4.2010, 09:20 (ссылка) | (нет голосов) Загрузка .

Шустрый

Профиль
Группа: Участник
Сообщений: 86
Регистрация: 19.7.2004

Репутация: нет
Всего: 1

ProgramerForever
Дата 26.4.2010, 09:33 (ссылка) | (нет голосов) Загрузка .

Опытный

Профиль
Группа: Участник
Сообщений: 554
Регистрация: 15.11.2006
Где: Новосибирск

Репутация: нет
Всего: 5

Romtek
Дата 27.4.2010, 13:26 (ссылка) | (нет голосов) Загрузка .

Бывалый

Профиль
Группа: Участник
Сообщений: 153
Регистрация: 7.12.2004
Где: Холон

Репутация: нет
Всего: 4

Цитата(ProgramerForever @ 15.4.2010, 15:43 )
do
Writeln(‘Press for end;’);
Writeln(‘Array[‘,i:1:0,’] = ‘);
Readln(a[i]);
i:=i+1;
until (a[i-1]<>»);

Разве в Паскале существует конструкция DO UNTIL?

Добавлено через 8 минут и 14 секунд
Writeln(‘Array[‘,i:1:0,’] = ‘);
Указывать i:1:0 можно только для действительных чисел.

ProgramerForever
Дата 27.4.2010, 15:21 (ссылка) | (нет голосов) Загрузка .

Опытный

Профиль
Группа: Участник
Сообщений: 554
Регистрация: 15.11.2006
Где: Новосибирск

Репутация: нет
Всего: 5

Ozzя
Дата 24.5.2010, 16:29 (ссылка) | (нет голосов) Загрузка .

Шустрый

Профиль
Группа: Участник
Сообщений: 86
Регистрация: 19.7.2004

Репутация: нет
Всего: 1

ProgramerForever
Дата 24.5.2010, 17:01 (ссылка) | (нет голосов) Загрузка .

Опытный

Профиль
Группа: Участник
Сообщений: 554
Регистрация: 15.11.2006
Где: Новосибирск

Репутация: нет
Всего: 5

Romtek
Дата 27.5.2010, 14:14 (ссылка) | (нет голосов) Загрузка .

Бывалый

Профиль
Группа: Участник
Сообщений: 153
Регистрация: 7.12.2004
Где: Холон

Репутация: нет
Всего: 4

Цитата(ProgramerForever @ 27.4.2010, 15:21 )
Да, там много косяков

А программа разве ещё неготова?

ProgramerForever
Дата 27.5.2010, 14:34 (ссылка) | (голосов:2) Загрузка .

Опытный

Профиль
Группа: Участник
Сообщений: 554
Регистрация: 15.11.2006
Где: Новосибирск

Репутация: нет
Всего: 5

1. Обсуждать и делится взломанными компонентами или программным обеспечением

2. Публиковать ссылки на варез

  • Действия модераторов можно обсудить здесь
  • С просьбами о написании курсовой, реферата и т.п. обращаться сюда
  • Вопросы по реализации алгоритмов рассматриваются здесь
  • 90% ответов на свои вопросы можно найти в DRKB (Delphi Russian Knowledge Base) — крупнейшем в рунете сборнике материалов по Дельфи

Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, THandle, Rrader, volvo877.

0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Object Pascal: кроссплатформенные технологии | Следующая тема »

[ Время генерации скрипта: 0.1584 ] [ Использовано запросов: 21 ] [ GZIP включён ]

Источник

Читайте также:  Leeco le max 2 x820 прошивка андроид 11

Adblock
detector

Ошибка в коде программы!

Модератор: Модераторы

Ошибка в коде программы!

Всем доброго времени суток.
В книге Алексеев Е. Р., Чеснокова О. В., Кучер Т. В. — Free Pascal и Lazarus(2010), есть пример такой программы:

Код: Выделить всё
var a, b, c, d, x1, x2: real;
begin
writeln (’Введите_коэффициенты_квадратного_уравнения’);
readln (a, b, c);
d:=b*b−4*a*c;
if d<0 then
begin
//Если дискриминант отрицателен, то вывод сообщения,
//что действительный корней нет и вычисление комплексных корней.
writeln (’Действительных_корней_нет’);
{Вычисление действительной части комплексных корней.}
x1:=−b/(2*a);
{Вычисление модуля мнимой части комплексных корней.}
x2:=sqrt(abs(d))/(2*a);
writeln ( ’Комплексные_корни_уравнения_’,
a:1:2, ’x^2+’ ,b:1:2, ’x+’ ,c:1:2, ’=0’ );
{Вывод значений комплексных корней в виде x1±ix2}
writeln (x1:1:2, ’+i*(’ ,x2:1:2, ’)’);
writeln (x1:1:2, ’−i*(’ ,x2:1:2, ’)’);
end
else
begin
{иначе вычисление действительных корней x1, x2}
x1:=(−b+sqrt(d))/2/a;
x2:=(−b−sqrt(d))/(2*a);
{и вывод их на экран.}
writeln ( ’Действительные_корни_уравнения_’ ,
a:1:2, ’x^2+’ ,b:1:2, ’x+’ ,c:1:2, ’=0’);
writeln (’X1=’ ,x1:1:2, ’X2=’ ,x2:1:2)
end end.

Когда я начинаю компилировать программу выходить такое сообщение об ошибке:
Fatal: Syntax error, «)» expected but «identifier B» found.
Не могу найти где эта ошибка
КТО-НИБУДЬ, ПОДСКАЖИТЕ!!!

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Дож » 27.10.2014 18:07:56

Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Аватара пользователя
Дож
энтузиаст
 
Сообщения: 891
Зарегистрирован: 12.10.2008 16:14:47

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 20:02:42

Дож писал(а):Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Little_Roo » 27.10.2014 20:40:10

какая строка с ошибкой?

Аватара пользователя
Little_Roo
энтузиаст
 
Сообщения: 632
Зарегистрирован: 27.02.2009 19:56:36
Откуда: Санкт-Петербург

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 21:35:18

Little_Roo писал(а):какая строка с ошибкой?

В этом-то и проблема. Я не могу найти строчку с ошибкой.
Полный текст ошибки такой:
Zero.pas (15,12) Fatal: Syntax error, «)» expected but «identifier B» found.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Little_Roo » 27.10.2014 21:38:27

Анна Бак писал(а):Zero.pas (15,12

Таки строка 15, позиция 12…. :shock:
Но это в ПОЛНОМ тексте кода программы….

Аватара пользователя
Little_Roo
энтузиаст
 
Сообщения: 632
Зарегистрирован: 27.02.2009 19:56:36
Откуда: Санкт-Петербург

Re: Ошибка в коде программы!

Сообщение Анна Бак » 27.10.2014 22:11:59

Little_Roo писал(а):Таки строка 15, позиция 12…. :shock:
Но это в ПОЛНОМ тексте кода программы….

СПАСИБО БОЛЬШОЕ!!! :D :D :D

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09

Re: Ошибка в коде программы!

Сообщение Дож » 27.10.2014 23:28:21

Анна Бак писал(а):

Дож писал(а):Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.

Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.

Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.

Разумно приводить на форуме именно неработающий код, потому что приведённый в первом посте после замены указанных мною символов на правильные благополучно компилируется и запускается.

Аватара пользователя
Дож
энтузиаст
 
Сообщения: 891
Зарегистрирован: 12.10.2008 16:14:47

Re: Ошибка в коде программы!

Сообщение Анна Бак » 28.10.2014 13:48:34

Дож писал(а):Разумно приводить на форуме именно неработающий код, потому что приведённый в первом посте после замены указанных мною символов на правильные благополучно компилируется и запускается.

Спасибо. Постараюсь.

Анна Бак
новенький
 
Сообщения: 13
Зарегистрирован: 11.02.2014 13:23:09


Вернуться в Обучение Free Pascal

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3

Status
Not open for further replies.

  • #1

Program TypeofCreditCard;
Var
AppliName: array[1..99] of String;
SSnum: array[1..99] of Integer;
GSal: array[1..99] of Integer;
TSalD: array[1..99] of Integer;

Name, CC : String;
Rep,Exp, GS,NS,Sum,TSD , YS,SSN,i,C_Amt,PofIncome : integer ;

Begin
Writeln ( ‘Enter applicants who applied for a type of credit card’);
Readln (Rep,Exp,GS,YS,NS,Sum,TSD,SSN,CC,PofInco… ;

While ( Name <> ‘ Stop ‘ ) do
Begin
NS:= GS-TSD ;
Sum:= Exp + Rep ;
PofIncome:=(NS * 0.45);
Begin
If ( GS >4000) AND ( CC = ‘Bronze Card’ ) then
YS:= GS * 12 ;
C_Amt := YS * 0.25;
i:= i + 1;
AppliName := Name;
SSNum := SSN ;
GSal [ i]:= GS ;
TSalD := TSD ;
End ;
Begin
If (GS >= 7500) AND [CC= ‘Gold Card’] then
YS:= GS * 12 ;
C_Amt:= YS * 0.3;
i:= i + 1 ;
AppliName := Name;
SSnum:=SSN;
GSal:=GS;
TSalD:=TSD;
End;
Begin
If (GS>=10,000) AND ( CC = ‘ Platinum Card’) then
YS := GS * 12;
C_Amt: = YS * 0.4;
i:= i + 1;
A ppliName := Name;
SSNum := SSN;
GSal :=GS;
TSalD := TSD;

End if
End if
End if
End While
End.

The five errors are :
1. Error:Incompatible types: got «Boolean» expected «LongInt» — For this line : If (GS >= 7500) AND [CC= ‘Gold Card’] then

2.Error:Incompatible types: got » Set of Boolean» expected » LongInt» — for the same line (If (GS >= 7500) AND [CC= ‘Gold Card’] then )

3.Error:Incompatible types: got «single» expected «smallint» — for C_Amt := YS * 0.25 ; in Bronze Card

4.Error:Incompatible types: got «extended» expected «smallint» for C_Amt := YS * 0.3; in Gold Card

5.Fatal:syntax error , «)» expected but «,» found — (If GS >= 10000) AND [CC= ‘Platinum’] then )

Thanks for any help. I know my program is by no means perfect because I am awful at Pascal and desperately need help on fixing these things. So I am open to anything that will get this program running in Pascal. Thanks.

Hawkeye22



Feb 10, 2006



713



0



19,460

95


  • #2

1 & 2. Square brackets should be parenthesis:
This: If (GS >= 7500) AND [CC= ‘Gold Card’] then
Should be this: If (GS >= 7500) AND (CC= ‘Gold Card’) then

3 & 4:
You have C_Amt and YS declared as integer yet you are multiplying by a real.

5: there should be no parenthesis at the end of that line.

Your code is hard to read. try indenting where needed. if it was already indented before you copied/pasted, then use the [code ] bbcodes in order to keep the formatting.

Hawkeye22



Feb 10, 2006



713



0



19,460

95


  • #2

1 & 2. Square brackets should be parenthesis:
This: If (GS >= 7500) AND [CC= ‘Gold Card’] then
Should be this: If (GS >= 7500) AND (CC= ‘Gold Card’) then

3 & 4:
You have C_Amt and YS declared as integer yet you are multiplying by a real.

5: there should be no parenthesis at the end of that line.

Your code is hard to read. try indenting where needed. if it was already indented before you copied/pasted, then use the [code ] bbcodes in order to keep the formatting.

Onus



Jan 27, 2006



724



0



19,210

64


  • #3

Well for one thing, the «[» and «]» may not be used in place of parentheses «(» and «)» in boolean expressions to be evaluated. Second, if you want to assign the integer portion of a real number to an integer variable, you need to use a function like TRUNC, as in «integer_var := TRUNC(real_expression);»



Jan 13, 2011



4,165



4



35,260

1,357


  • #4

This is how your program looks when enclosed in [ code ] and [ / code ] tags:

Program TypeofCreditCard; 
Var 
    AppliName: array[1..99] of String; 
    SSnum: array[1..99] of Integer; 
    GSal: array[1..99] of Integer; 
    TSalD: array[1..99] of Integer; 

    Name, CC : String; 
    Rep,Exp, GS,NS,Sum,TSD , YS,SSN,i,C_Amt,PofIncome : integer ; 

Begin 
    Writeln ( 'Enter applicants who applied for a type of credit card'); 
    Readln (Rep,Exp,GS,YS,NS,Sum,TSD,SSN,CC,PofInco... ; 

    While ( Name <> ' Stop ' ) do 
    Begin 
        NS:= GS-TSD ; 
        Sum:= Exp + Rep ; 
        PofIncome:=(NS * 0.45); 
        Begin 
            If ( GS >4000) AND ( CC = 'Bronze Card' ) then 
                YS:= GS * 12 ; 
            C_Amt := YS * 0.25; 
            i:= i + 1; 
            AppliName := Name; 
            SSNum := SSN ; 
            GSal [ i]:= GS ; 
            TSalD := TSD ; 
        End ; 
        Begin 
            If (GS >= 7500) AND [CC= 'Gold Card'] then 
                YS:= GS * 12 ; 
            C_Amt:= YS * 0.3; 
            i:= i + 1 ; 
            AppliName := Name; 
            SSnum:=SSN; 
            GSal:=GS; 
            TSalD:=TSD; 
        End; 
        Begin 
            If (GS>=10,000) AND ( CC = ' Platinum Card') then 
                YS := GS * 12; 
            C_Amt: = YS * 0.4; 
            i:= i + 1; 
            AppliName := Name; 
            SSNum := SSN; 
            GSal :=GS; 
            TSalD := TSD; 
        End if 
        End if 
        End if 
    End While 
End.



Jan 13, 2011



4,165



4



35,260

1,357


  • #5

(sorry for double-post, it will be easier)…

Appart from the errore already discussed, there are some more:
— there are not «end if» and «end while» operators in Pascal (OK, at least in the popular ones);
— your ReadLn statement probably won’t work — string variables will get empty values. Split it on several Write / ReadLn statements
— you have several arrays, but assignment statements are missing [Index] part of the array, e.g. AppliName := Name;
— you are not checking if one will enter more that 100 applicants

  • #6

Thank you everyone. I will give you all an update when i incorporate all of these corrections.

By the way, I am using Free IDE Pascal .

Onus



Jan 27, 2006



724



0



19,210

64


  • #7

I used to use Turbo Pascal. Ah, those were the days…

  • #8

I’m down to 2 errors now and I am pleased but I just really need it to run.
This is the error — Fatal:Syntax Error, «;» expected but «identifier Writeln found — Source of error- Writeln ( ‘Enter applicants who applied for a type of credit card’);

Is there some sort of documentation about what each error means??I want to learn.

Ijack



Jul 30, 2008



1,035



0



20,360

113


  • #9

The message means exactly what it says. The compiler was expecting to find «;» but instead it found «Writeln». Normally this means the semicolon is missing from the line before the one listed but your program, as you list it, has no statement before that line. Have you added something since?

  • #10

The message means exactly what it says. The compiler was expecting to find «;» but instead it found «Writeln». Normally this means the semicolon is missing from the line before the one listed but your program, as you list it, has no statement before that line. Have you added something since?

I’ve done nothing but do the changes I’ve been told to made.



Jan 13, 2011



4,165



4



35,260

1,357


  • #11

@Tactical, post your complete code, here or on e.g. PasteBin. If you post it here, encclose it in «code» tags
that is, (omit ‘_’ from example below)
[_code_]
Program something;

end.
[_/code_]

Ijack



Jul 30, 2008



1,035



0



20,360

113


  • #13

You have deleted the «Begin» between the variable declarations and the program statements. Reinstate it (just before the offending line) and try again.

  • #14

You have deleted the «Begin» between the variable declarations and the program statements. Reinstate it (just before the offending line) and try again.

I inserted that beginning then one more error came up and it said
Fatal syntax error, «;’ expected but » BEGIN» found



Jan 13, 2011



4,165



4



35,260

1,357


  • #15

@Tactical — it would be helpful if you mention what compiler you’re using, and (when errors happen) — at what line.

On your program:
— Put a «Begin» before first «WriteLn»;
— Put «I := 0» before «while» statement
— change «while» to check that I is less than 100
— change internal «If» to check for «Name <> ‘Stop'»
— Remove last two «End;» before «End.»;

Probably there are more… Change your program, re-post it on PasteBin for further help

  • #16

So i followed through and continued to attempt to run the program and eventually after trying to follow and fix every error , I think it started running but i don’t understand because its been more than 5 hours now that it has said that the PASCAL file is now running but i can not type anything in the black screen and it can not be closed down.Additionally, because I didn’t know it would run after i corrected the last error, this means that I have not saved the most recent version of the PASCAL yet. The problem with that is for my assignment it says » You have to show evidence that your program ran (a print screen after it compiled. Print screen of some data that you entered and a print screen of the output) «

Will it ever run or come off of this screen that it seems to be stuck on?



Jan 13, 2011



4,165



4



35,260

1,357


  • #17

@Tactical — for God’s sake, what version of Pascal are you using?
Try pressing <Ctrl>-<Break>, or <Ctrl>-C, to terminate your program. If you have a debugger in your environment, you can try to terminate your program from there as well.

And since we don’t know how your program looks now, noone can tell what will come out of it ;)

Ijack



Jul 30, 2008



1,035



0



20,360

113


  • #18

The last version of the program that you listed had an infinite loop in it. You never change the value of «Name» inside the «While» loop. This is why the program keeps running.

As the previous poster said, just break into the program. How you do that depends upon your environment.

Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date

B

Solved! Apple Community Reload Error Apps General Discussion 4 Jun 14, 2022

K

Question cache deleted in error Apps General Discussion 1 Apr 25, 2022

xarzu

Question How do I update my computer because I have an error? Apps General Discussion 0 Apr 12, 2022

C

Question Photoshop Elements 2021 error codes 81 and 501 won’t allow installation? How to fix. Apps General Discussion 1 May 5, 2021

aymen9309

Question i need help in a simple pascal program Apps General Discussion 1 Jun 18, 2020

David___Only

Question How to fix“ ERROR-invalid argument/option — ‘Live’ ” in this code? Apps General Discussion 0 Jul 21, 2019

KloneCSGO

Question PUBG Lite launcher error Apps General Discussion 2 Jul 1, 2019

reble

Question Win dos shell syntax error Apps General Discussion 2 Apr 11, 2019

I

Solved! Getting error 502 Bad Gateway, is it proxy or website itself Apps General Discussion 5 Jan 23, 2019

U

ASCII in Pascal programming Apps General Discussion 4 Dec 13, 2015

A

Pascal homework help Apps General Discussion 2 Mar 7, 2015

shiftyape

need help with pascal programming Apps General Discussion 4 Feb 22, 2014

shiftyape

why wont this pascal program work? idk Apps General Discussion 18 Dec 13, 2013

shiftyape

need help with this pascal programming. Apps General Discussion 3 Dec 13, 2013

shiftyape

why doesnt this pascal program work? Apps General Discussion 1 Dec 7, 2013

shiftyape

need help with pascal programming? Apps General Discussion 2 Dec 7, 2013

shiftyape

i need help fixing this pascal program Apps General Discussion 13 Dec 5, 2013

L

Which programming languages will I need to learn as an actuary? Apps General Discussion 2 Dec 12, 2012

M

** A CHALLENGE ** UCSD P-sytem Pascal ** Apps General Discussion 7 Oct 15, 2010

P

pascal quation.. Apps General Discussion 7 Nov 13, 2008

  • Advertising
  • Cookies Policies
  • Privacy
  • Term & Conditions
  • Topics

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Fatal syntax error expected but const char found
  • Fatal syntax error begin expected but end of file found lazarus
  • Fatal string manager failed to initialize properly как исправить ошибку
  • Fatal string manager failed to initialize properly red alert 2 ошибка fatal
  • Fatal simulation error encountered proteus 8

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии