Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14007

This Forum Only

Arrays of Records Posted by rexxdragon on 14 Jun 2012 at 7:13 PM
I cannot get the program to continue past If (choice=5), the program stops there and refuses to calculate the other segement. Any advice would be appreciated.

Program program;
Uses Wincrt;
TYPE
Band_Reports=Record
Masquaraders:string;
People:integer;
Cost:integer;
Income_Sum:integer;
End;
Band=Array [1..5]of Band_Reports;
VAR
B:Band;
x,choice:integer;
Begin
B[1].People:=0;
B[2].People:=0;
B[3].People:=0;
B[4].People:=0;
B[5].People:=0;
For x:= 1 to 5 Do
Begin
Write('Enter masquarader name:');
Readln(B[x].Masquaraders);
Writeln('1.Barbados-\$160');
Writeln('2.Miami-\$220');
Writeln('3.St.Lucia-\$280');
Writeln('4.Brazil-\$350');
Writeln('5.Trinidad-\$425');
Repeat
Write('Enter choice:');
Readln(choice);
Until (choice>=1)AND(choice<=5);
If (choice=1) then
Begin
Writeln('Section: Barbados');
B[1].Cost:=\$160;
B[1].People:=B[1].People+1;
End;
If (choice=2) then
Begin
Writeln('Section: Miami');
B[2].Cost:=\$220;
B[2].People:=B[2].People+1;
End;
If (choice=3) then
Begin
Writeln('Section: St.Lucia');
B[3].Cost:=\$280;
B[3].People:=B[3].People+1;
End;
If (choice=4) then
Begin
Writeln('Section: Brazil');
B[4].Cost:=\$350;
B[4].People:=B[4].People+1;
End;
If (choice=5) then
Begin
Writeln('Section: Trinidad');
B[5].Cost:=\$425;
B[5].People:=B[5].People+1;
End;
If (B[1].Cost=160) then
Begin
Writeln;
Writeln;
Writeln('Section:Barbados');
Writeln;
Writeln('Name of Masquarader:',B[x].Masquaraders);
Writeln('Number of Maquaraders:',B[1].People);
B[1].Income_Sum:= B[1].People*B[1].Cost;
Writeln('Total income for Barbados=\$',B[1].Income_Sum);
End;
End;
readkey
End.

Thread Tree
rexxdragon Arrays of Records on 14 Jun 2012 at 7:13 PM