Good day,
Firstly, I am new to pascal, I am only trying to assist my brother.
I am faced with a problem of adding data to arrays and I may need some help searching the array as well.
The program is suppose to allow the user to enter the name, status and country of origin and with this data perform some calculations which I think i can figure out once am past this step. The user must also set the arrays in a way that when they search they bring up the information of the user.
Below is what I have thus far.

 program tourismworkshop;

 uses crt;

 const
    hotel = 280.80;
    tax = 55.00;
    psub = 500.00;
    pasub = 400.00;
 var
    nm: integer;
    names: array[1..6] of string;
    stat: integer;
    status: array[1..6] of string;
    coo: integer;
    country: array[1..6] of string;
begin
 write ('Tourism Workshop');
 for nm:= 1 to 6 do
  begin
    write('Enter Name ');
    readln(names[nm]);
  end;
  begin
    write('Enter status ');
    readln(status[stat]);
  end;
  begin
    write('Enter country of origin ');
    readln(country[coo]);
  end;
write ('Displaying tourism workshop database ');
for nm:= 1 to 6 do
begin

    write('The information stored ')
    writeln(names[nm]);
    writeln(status[stat]);
    writeln(country[coo]);
end;
end.

Not sure what your question is, but you have a few little errors in your code.
1. You have the code blocks (begin...end) for 3 loops but you only have the "for" statement for the first loop.
2. You have missed a semi-colon at the end of a line.
3. You have missed an "end;". There should be one for every "begin".
4. The statements in your output loop are all using a different array index variable. They should all use the loop control variable to specify which index element to output.

I did a rewrite from your line 18 on:

 write ('Tourism Workshop'); (*line 18*)
 for index:= 1 to 6 do (*define index as an integer*)
  begin
    write('Enter Name ');
    readln(names[index]);
    write('Enter status ');
    readln(status[index]);
    write('Enter country of origin ');
    readln(country[index]);
  end;

Hope this clears things out for the rest of your program.

So I got the program to read in the data correctly(thanks to ddanbe), now I am unto my next issue. Getting it to do arthemtic operations. I want each person in the array to have their own total. I am thinking of doing 6 if / else if statements to work out the totals but am unsure of how to go about this or if there's a better way. The total for an individual would depend on their country of origin, departure tax, hotel charge and if they are a presenter or participant. If I could get one of the if statements correct I should be able to do the rest.

 program tourismworkshop;

 uses crt;

 const
    hotel = 280.80;
    tax = 55.00;
    psub = 500.00;
    pasub = 400.00;
 var
    names: array[1..6] of string;
    status: array[1..6] of string;
    country: array[1..6] of string;
    index: integer;
    sub1: integer;
    sub2: integer;
    sub3: integer;
    sub4: integer;
    sub5: integer;
    sub6: integer;
    total: integer;
begin
clrscr;
 write ('Tourism Workshop');
 writeln;
 for index:= 1 to 6 do
begin
    write('Enter Name ');
    readln(names[index]);
    write('Enter Status ');
    readln(status[index]);
    write('Enter country of origin ');
    readln(country[index]);
end;
begin
if status[1]= 'presenter' then
sub1:= psub+total;
else if status[1]='participant' then
sub1:= pasub+total;
writeln('The total for 'name[1], 'is' sub1)
end;
end.

Put your if / else in a for loop. Use index as the loop counter again. Replace [1] with [index].
Don't know exactly why you use the same sub1 on line 37 and 39.
What is sub1? Try to use more meaningfull variable names.

I assume that sub1 - sub6 are the sub-totals for each person. In which case, rather than having 6 separate sub-totals, would it make sense to put them into a single array?

Also with the totals in an array, you could then use a loop to go through each persons data and store each persons total in the appropriate place in the array of totals.

In fact looking at your code again, would it not be better to use something like a Record to store the details for each person (name, status, country, total)?(see here for more on records).

That way, rather than having 6 peoples data spread out across four different arrays, you have a single array containing 6 Records, one for each person.

Records allow you to collect several different types of related data in one single type.

If you haven't covered Records in your programming class yet, ignore the suggestion. But if you are aware of them, it might be worth considering. It would clean up your code quite a bit!

No we haven't reached records as yet. I was reading up about two and 3 dimensional arrays but I am not sure how to implent it.

Ok I reached a point where I need the input that goes into the status array to set the number in the sub array from 1 to 6. if the status1 is participant i want it to set the sub1 block as 500 else set it to presenter. I am unsure on how I should really go about it.

 program tourismworkshop;

 uses crt;

 const
    hotel = 280.80;
    tax = 55.00;
    psub = 500.00;
    pasub = 400.00;
 var
    names: array[1..6] of string;
    status: array[1..6] of string;
    country: array[1..6] of string;
    sub: array[1..6] of integer;
    index: integer;
    total: integer;
begin
clrscr;
 write ('Tourism Workshop');
 writeln;
 for index:= 1 to 6 do
begin
    write('Enter Name ');
    readln(names[index]);
    write('Enter Status ');
    readln(status[index]);
    end;
    begin
    if presenter(status[index]) in[1..6] then
    readln(sub[index])=500;
    elseif participant(status[index]) in[1..6] then
    readln(sub[index])=400;
end;
begin
    write('Enter country of origin ');
    readln(country[index])
end;

end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.