Link to home
Start Free TrialLog in
Avatar of seraph_matrix_631
seraph_matrix_631Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Creating a program to store text in an array

Hello all.
I am having some issues with a pascal program i am creating. I have got a prompt, "Please Enter The Name of The Employee Whoose Allowance Will Be Calculated: "

the entered data needs to be stored in an array. The program then loads my menu of three choices, and the prompt underneath needs to say, "Please Enter <NAME OF EMPLOYEE>'s Means of Transport: "

the type of transport chosen (a number) also needs to be stored in this array.
the program then asks how much ileage the customer has driven using the set mode of transport. this must also be stored in the array. the calculated allowance  should be calculated and stored in an array.

the programmust loop after the first array has been stored and then accept new entries to be stored as mentioned above.
The program should then close if the user enter's FINISH as the employee name.


this then  has to go on and display an onscreen report with the employee name, vehicle type, weekly mileage and allowance.

i have allocated all my points to this question as i can see its a big task.
thank you in advance.

Seraph
Avatar of Mike McCracken
Mike McCracken

Seraph - EE experts will not do your homework for you.  We will help with specific questions.  Please post the code you have thus far.  If you don't have any code then please post your algorithm and the data type and declarations you anticipate using.

mlmcc
SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As far as I understand the problem:
- there can be many employees entered.
- each employee can use many modes of transport
- the mileage should be stored for every mode of transport an employee used.

There are a few problems to be considered, before going further.
- is the amount of transport modes restricted or predefined. Means: Should the program accept new forms of transportation, or just to ask to chose one from the predefined list?
- How many empoyees the program should support?
- The program has to do some calculations. Every mode of transportation has a different mileage to allowance ratio. But, is it a predefined value, or it should be entered by the user, perhaps?
Avatar of seraph_matrix_631

ASKER

mlmcc
this is not homework. This is me experimenting with the programming language and me trying to better my programming skills.


----CODE START----

PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

VAR            TOTALREC            :INTEGER;
            MILES                  :INTEGER;
            ALLOWANCE            :REAL;
            SELECTION            :INTEGER;
            EMPNUM                  :INTEGER;
            
BEGIN

      WRITE('HOW MANY RECORDS DO YOU WISH TO PROCESS:> ');
      READ(TOTALREC);

            FOR EMPNUM:=1 TO TOTALREC DO
            BEGIN
            
      CLRSCR;
      WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
      WRITELN;
      WRITELN('1-MOTORCYCLE');
      WRITELN('2-CAR WITH LESS THAN 1500 CC CAPACITY');
      WRITELN('3-CAR WITH MORE THAN 1500 CC CAPACITY');
      WRITELN;
      WRITE('PLEASE ENTER TRANSPORT FOR EMPLOYEE ', EMPNUM);
    WRITE(': ');
    READ(SELECTION);

      
      
            IF (SELECTION=1) THEN
            BEGIN
        WRITE('PLEASE ENTER MILEAGE:> ');
            READLN(MILES);
            ALLOWANCE:=MILES*0.15;
        CLRSCR;
        WRITELN;
            WRITELN('YOU SELECTED MOTORCYCLE AS YOUR MEANS OF TRANSPORT');
            WRITELN('YOUR WEEKS MILEAGE IS ', MILES);
            WRITELN('YOUR TRAVELLING ALLOWANCE IS ', ALLOWANCE:4:2);
            WRITELN;
            WRITE('PRESS ANY KEY TO CONTINUE...');
            DELAY(2000);
            READKEY;
        CLRSCR;
            END;
            
            
            
            IF (SELECTION=2) THEN
            BEGIN
        WRITE('PLEASE ENTER YOUR MILEAGE:> ');
            READLN(MILES);
            ALLOWANCE:=MILES*0.20;
        CLRSCR;
        WRITELN;
            WRITELN('YOU SELECTED A CAR WITH LESS THAN 1500 CC CAPACITY AS YOUR MEANS OF TRANSPORT');
            WRITELN('YOUR WEEKS MILEAGE IS ', MILES);
            WRITELN('YOUR TRAVELLING ALLOWANCE IS ', ALLOWANCE:4:2);
            WRITELN;
            WRITE('PRESS ANY KEY TO CONTINUE...');
            DELAY(2000);
            READKEY;
        CLRSCR;
            END;
            
            
            
            IF (SELECTION=3) THEN
            BEGIN
        WRITE('PLEASE ENTER YOUR MILEAGE:> ');
            READLN(MILES);
            ALLOWANCE:=MILES*0.30;
        CLRSCR;
        WRITELN;
            WRITELN('YOU SELECTED A CAR WITH MORE THAN 1500 CC CAPACITY AS YOUR MEANS OF TRANSPORT');
            WRITELN('YOUR WEEKS MILEAGE IS ', MILES);
            WRITELN('YOUR TRAVELLING ALLOWANCE IS ', ALLOWANCE:4:2);
            WRITELN;
            WRITE('PRESS ANY KEY TO CONTINUE...');
            DELAY(2000);
            READKEY;
        CLRSCR;
            END;

IF (EMPNUM=TOTALREC+1) THEN
END;
end.
-----CODE END----


thanks in advance
- is the amount of transport modes restricted or predefined. Means: Should the program accept new forms of transportation, or just to ask to chose one from the predefined list?

:::as  sataed in code above, the options are predefined and no additional modes of transport need to b added.



- How many empoyees the program should support?

:::an infinate number, what i am tryiong to do is tomake the system loop after each employee and for the datya to be stored in an array for each member - when the user types "FINISH" as the employee name the program should not ask for user input and show a report of all the arrays stored (shows all processed employees)



- The program has to do some calculations. Every mode of transportation has a different mileage to allowance ratio. But, is it a predefined value, or it should be entered by the user, perhaps?

:::Again this is predefined as my code states above.

seraph.
I see two possible solutions.

1) to store all records entered in an array or a pointer list. The array is limited with size to (65536-16) div (SizeOf (Real)+4*SizeOf (Integer)) equal 5460 elements. The pointer list is limited by all memory available to the program.
2) to make an array storing allowance data in relation to mode of transportation and employee number. So, the table would have as many columns as amount of modes of transportation, and as many rows as the amount of employees. The program should add every entered record to the proper table element, instead of storing all entered records. The final pesentation would just print the array, instead of making any calculations.

As for the main loop of the program. FOR loop is not a good choice to do what you want. I would suggest a:

while [condition] do
 begin
  .............
 end;
(exits loop on [condition]=false)

or:

repeat
   .........
until [condition];
(exits loop on [condition]=true)
For-Soft ... I am sorry but that went straight over my head!!
Please could you explain that using less Jargon please?

Much Appreciated!
Skulls  :-)
1) The program can store every record entered in an array or a list. After finishing entering data, program would make calculation and data presentation.
(the amount of records rememberes is restricted by maximum table size, or the amount of memory)

2) Program does not have to store every record. It can store the total results in a table, instead. Every record entered would be added to the results table. So, after entering all data there would be no calculations part, just the presentation of the results.
(the table size is dependant on amount of workers (rows) and amount of modes of transportation (columns). There is no limit to amount of records entered.
urm...
how would i do that?

I am all confused. Seen some sites that explain it but its explained in too much detail for me to understand how to adapt it for my program, or to at least understand how to do it.
I give up. I'm not going to write two separate programs in order to explain two possible solutions.

In order to continue, you have to chose one way or the other.
Apologies. I think option 1 would be best to do as it meets what i need.

so you enter the data.
the program loops - you enter more data

when you type finish the program lists the entered data, which is stored in the array.

sorry for being Dense.
got a lot of shit in my life ATM.
So, you will need an array to store data records in. You should create a data record type, and then you will be able to create the array type and variable.

Depending on the pascal compiler version, the size of the array is limited by maximum data block size, and amount of the program stack memory available. It will be necesary to store the amont of records stored in the array in a variable of some sort.

so what code can i use to do this?
Const MaxRecords=500;

Type
 ADataRecord=record
          MILES               :INTEGER;
          ALLOWANCE          :REAL;
          SELECTION          :INTEGER;
          EMPNUM               :INTEGER;
          end;

 ADataRecordsArray=array [1..MaxRecords] of ADataRecord;

var DataRecordArray: ADataRecordsArray;
hello all.
thank you for the reply For-Soft.

I was playing around with my code today and have done it different to you. it works which is the maint hing and it displays the data how i want it to be displayed afterwards. will now work on how to get it so you can add data and if a name is typed (FINISH) it then leads on to displaying the list of imput data.

This is the code i have used. :-)




PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

VAR            MILES                  :ARRAY [1..10] OF INTEGER;
            ALLOWANCE            :ARRAY [1..10] OF REAL;
            SELECTION            :ARRAY [1..10] OF INTEGER;
        NAME            :ARRAY [1..10] OF STRING;
        LOOP            :INTEGER;


BEGIN
      WRITELN('=================================================');
    WRITELN('=   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('=   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('=                                               =');
    WRITELN('=                                               =');
    WRITELN('=                          DATE:  23/11/2006    =');
    WRITELN('=================================================');

    WRITELN;



    FOR LOOP := 1 TO 700 DO
    BEGIN
            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
            READLN(NAME[LOOP]);

                 CLRSCR;
                  WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                  WRITELN;
                  WRITELN('1    MOTORCYCLE');
                  WRITELN('2    CAR WITH LESS THAN 1500 CC CAPACITY');
                  WRITELN('3    CAR WITH MORE THAN 1500 CC CAPACITY');
                  WRITELN;
                  WRITE('PLEASE ENTER ', NAME[LOOP]);
                WRITE('S METHOD OF TRANSPORT:');
                    READ(SELECTION[LOOP]);

                                IF (SELECTION[LOOP]=1) THEN
                                BEGIN
                            WRITE('PLEASE ENTER MILEAGE:> ');
                            READLN(MILES[LOOP]);
                                  ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                            CLRSCR;
                            END;

            
                            IF (SELECTION[LOOP]=2) THEN
                            BEGIN
                            WRITE('PLEASE ENTER YOUR MILEAGE:> ');
                            READLN(MILES[LOOP]);
                            ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                            CLRSCR;
                            END;

            
                            IF (SELECTION[LOOP]=3) THEN
                              BEGIN
                            WRITE('PLEASE ENTER YOUR MILEAGE:> ');
                            READLN(MILES[LOOP]);
                            ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                            CLRSCR;
                            END;
     END;  {END LOOP}


    WRITELN('NAME:     TRANSPORT:       MILEAGE:       ALLOWANCE:');
    WRITELN('======================================================================');

    FOR LOOP:=1 TO 700 DO
    BEGIN
         WRITELN(LOOP:2,' - ',NAME[LOOP],'     ',SELECTION[LOOP] ,'    ',MILES[LOOP]);
    END;

    WRITELN('PRESS ANY KEY TO CONTINUE...');
    READKEY;


end.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow...
That really simplifies things...
so instead of:


if (selection=1) then
allowance := Miles * 0.15
...

if (selection := miles * 0.20
...


i could get rid of all three instances of the above and replace it with:

  WRITE('PLEASE ENTER MILEAGE:> ');
  READLN(MILES[LOOP]);
  IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
  IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
  IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
  CLRSCR;

one thing how would i be able to say in code that if the user types 1 as the mode of transport then the report at the end shows MOTORCYCLE instead of "1".

Thank you so much for your help.
Seraph.
"one thing how would i be able to say in code that if the user types 1 as the mode of transport then the report at the end shows MOTORCYCLE instead of "1". "

Pretty much the same way:
IF (SELECTION[LOOP]=1) THEN Write ('MOTORCYCLE');
IF (SELECTION[LOOP]=2) THEN ...........

But, the shortest way would be through an array (constant array).

First it would require to declare a variable or constant with the possible values in it

CONST TransportArray: array [1..3] of String [40] = ('MOTORCYCLE','CAR WITH LESS THAN 1500 CC CAPACITY','CAR WITH MORE THAN 1500 CC CAPACITY');

But, it will be possible to print the text value in just one line of code, depending on the SELECTION[LOOP] value.

Write (TransportArray[SELECTION[LOOP]]);

So, the TransportArray[1] is equal to 'MOTORCYCLE'. And when SELECTION[LOOP] equals 1 the MOTORCYCLE word will be printed.
Helo Experts. I have been adding to my code to try and get the program to loop until the user types FINISH as the employee name.
When this happens all input records are shown. (all records are shown if the maxrecords=maxrecords)

i cant seem to get it right. what i ahve below compiles, btu then exceeds the MaxRecords counter.
====
Also i have been trying to validate the menu options. So if the user entered "5" a message should appear warning the user that it is an invalid menu option and then ask them to re-enter the menu selection (without saving the incorrect value entered to the array).



PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

CONST   MAXRECORDS      =10;

VAR            MILES                  :ARRAY [1..MAXRECORDS] OF INTEGER;
            ALLOWANCE            :ARRAY [1..MAXRECORDS] OF REAL;
            SELECTION            :ARRAY [1..MAXRECORDS] OF INTEGER;
        NAME            :ARRAY [1..MAXRECORDS] OF STRING;
        LOOP            :INTEGER;



    BEGIN

    WRITELN;
    WRITELN('  =================================================');
    WRITELN('  =   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('  =   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('  =                                               =');
    WRITELN('  =                                               =');
    WRITELN('  =                          DATE:  23/11/2006    =');
    WRITELN('  =================================================');

    WRITELN;

    FOR LOOP := 1 TO MaxRecords DO
    BEGIN

           REPEAT
            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
            READLN(NAME[LOOP]);


                  CLRSCR;
                  WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                  WRITELN;
                  WRITELN('   1    MOTORCYCLE');
                  WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                  WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                  WRITELN;


                :ENTERTRANSPORT             {PASCAL LABEL NAME FOR THE BELOW CODE...}
                  WRITE('PLEASE ENTER ', NAME[LOOP]);
                WRITE('S METHOD OF TRANSPORT:> ');
                READ(SELECTION[LOOP]);

       IF (Selection[loop] not =1,2,3) then
       Writeln;
       Writeln('You have entered an invalid selection');
       GOTO :ENTERTRANSPORT             {CALLS THE PASCAL LABEL AND EXECUTES THE CODE IF THE INCORRECT VALUE IS ENTERED}
       end;



                WRITE('PLEASE ENTER MILEAGE:> ');
                READLN(MILES[LOOP]);
                IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                CLRSCR;

           UNTIL NAME[LOOP]='FINISH';
         END;  {END LOOP}



    WRITELN('END SYSTEM REPORT:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO MaxRecords DO
    BEGIN
         WRITELN('RECORD:  ', LOOP:3);
         WRITELN('NAME:      ',       NAME[LOOP]);

            IF (SELECTION[LOOP]=1) THEN WRITELN ('TRANSPORT: MOTORCYCLE ');
            IF (SELECTION[LOOP]=2) THEN WRITELN ('TRANSPORT: CAR WITH LESS THAN 1500 CC CAPACITY ');
            IF (SELECTION[LOOP]=3) THEN WRITELN ('TRANSPORT: CAR WITH MORE THAN 1500 CC CAPACITY ');

         WRITELN('MILEAGE:   ',     MILES[LOOP]);

         {WRITE THE ALLOWANCE USING THE POUND SIGN HEX CODE}
         WRITE('ALLOWANCE: ');
         WRITE(#156);
         WRITE( ALLOWANCE[LOOP]:4:2);

         WRITELN;
         WRITELN;
    END;
    WRITELN;
    WRITELN('PRESS ANY KEY TO CONTINUE...');
    READKEY;

end.
Replace the input looping code with


           LOOP :=0;
           REPEAT
                LOOP := LOOP + 1;
                WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
                READLN(NAME[LOOP]);

                 CLRSCR;
                 WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                 WRITELN;
                 WRITELN('   1    MOTORCYCLE');
                 WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                 WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                 WRITELN;

                 Repeat
                      WRITE('PLEASE ENTER ', NAME[LOOP]);
                      WRITE('S METHOD OF TRANSPORT:> ');
                      READ(SELECTION[LOOP]);

                     IF (Selection[loop] < 1) OR (Selection[LOOP] > 3)  then
                         Begin
                               Writeln;
                               Writeln('You have entered an invalid selection');
                         End;
                Until (Selection[loop] >= 1) AND (Selection[LOOP] <= 3)

                WRITE('PLEASE ENTER MILEAGE:> ');
                READLN(MILES[LOOP]);
                IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                CLRSCR;

           UNTIL (NAME[LOOP]='FINISH') OR (LOOP = MaxRecords);

mlmcc
This loop has a disadvantage. Because, the program will require to enter form of transportation after the word "FINISH" was entered.

The simplest addition to the current code would be to put all the code after entering name in the IF conditional statement.

Other way of doing it would be to put the data entering code in a procedure. Statement EXIT would exit the procedure if the condition would be met.

Procedure EnteringData;
 begin
    FOR LOOP := 1 TO MaxRecords DO
    BEGIN
    ......
                READLN(NAME[LOOP]);
                If NAME[LOOP]='FINISH' then
                                                      begin
                                                       Loop:=Loop-1;
                                                       Exit;
                                                      end;
    ......
    END;  {END LOOP}
 end;

BEGIN
...........
'  =================================================');

    WRITELN;

    EnteringData;

    WRITELN('END SYSTEM REPORT:');
    ..................
END.

Also you should not process all MaxRecord loops at the "end report" program section. You should rather declare another counter and make a loop from 1 to LOOP. So, records in table equal and above the "FINISH" will not be processed during the "end report" generation.
i am having problems with this. i have added the code from mlmcc (thanks!)
and it asks you to create a record (Array) for member called "Finish".


I tried your solution For-Soft and it doesnt want to work. It asks me to input the members name three times (for the first record) then the second record it prompts you to enter it once as usual.

eg:
[loads program]
Please enter name: BEN
Please enter name: BEN
please enter name: BEN

Please enter Ben's method of transport:  1
Milage:                                                 520

[[Stores Array Data]]
     [[Loops]]

Please enter name: BEN     <-  only asks for the name once
Please Enter Paul's method of transport:  2
Mileage:                                                200


The code is the same as most recent post with For-Soft's additions.
There is only one line asking for the name.
I have tried it in a different compiler (on my machine)  and have also tried copiling it on a different machine (has proven to work sometimes)  but to no avail.


Many thanks Skulls
His code was to fix a problem in my code.  Try it this way
Add a declaration
Var   InputName : String;

           LOOP :=0;
           REPEAT

                WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
                READLN(InputName);
                If InputName <> "Finish" then
                Begin
                    LOOP := LOOP + 1;
                    NAME[LOOP] := InputName;

                    CLRSCR;
                    WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                    WRITELN;
                    WRITELN('   1    MOTORCYCLE');
                    WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                    WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                    WRITELN;

                    Repeat
                        WRITE('PLEASE ENTER ', NAME[LOOP]);
                        WRITE('S METHOD OF TRANSPORT:> ');
                        READ(SELECTION[LOOP]);

                       IF (Selection[loop] < 1) OR (Selection[LOOP] > 3)  then
                       Begin
                             Writeln;
                             Writeln('You have entered an invalid selection');
                       End;
                   Until (Selection[loop] >= 1) AND (Selection[LOOP] <= 3)

                   WRITE('PLEASE ENTER MILEAGE:> ');
                   READLN(MILES[LOOP]);
                   IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                   IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                   IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                   CLRSCR;
                End;

           UNTIL (NAME[LOOP]='FINISH') OR (LOOP = MaxRecords);

mlmcc
Oops!

Mlmcc. There is a bug in your code.

You are testing the entered name once against 'Finish' to stop entering other data, then against 'FINISH' to exit the nain loop. Also you entered wrong string statement characters.

This can not work, as the Pascal string comaring is case sensitive. Both comparations have to be against the same string for this code to work properly.

I guess, you wanted to write:
    If InputName <> 'FINISH' then
You are correct on the comparison.  The comparison should be against whatever the user would enter.  A better comparison would be to use a function to uppercase or lowercase the input name to ensure case was not an issue.  I don't have Pascal loaded here so something like this for the first one

    If UCase(InputName) <> 'FINISH' then

and for the UNTIL

    UNTIL (Ucase(NAME[LOOP])='FINISH') OR (LOOP = MaxRecords);

mlmcc
So the UCase function declaration would be necesary.

Perhaps something like this, then:

function UCase (S: String): String;
 var Counter: Byte;
begin
 If Length (S)>0 then for Counter:=1 to Length (S) do S [Counter]:=UpCase (S [Counter]);
 UCase:=S;
end;

Looks good.  Couldn't remember if Pascal provided a function or not.

mlmcc
As far as I know, the Turbo Pacsal has the UpCase function, only. It can convert characters, but not strings.

I do not know about Open Pascal functions, but it could be one.
Strings.tpu

  StrUpper




uses
  strings;

var
  s: string;

begin
  s:='hello';
  writeLn(s);
  strupper(@(s));
  writeLn(s)
end.
hello all. thank you for all the responces. had a network error which i had to correct so i was not online to receive comments.

currently unwell - going to rest up in bed.
head is pounding so i cant look at this screen for long. just letting you know that i will get back to you probably by tomorrow if not by the end of the wekeend.

thank you all for your help it is greatly appreciated.

Skulls.

p.s - from what i have seen - some nice code!  Well done fellow programmers!
Hello All, Still a little unwell but have been going through this code and there are still some problems with the code.  When FINISH is entered as the name, it shouldn't prompt for the transport or mileage - instead if 'FINISH' is typed it should show all entries that have been entered prior to the current record.

EG:

Record 1:
Name:        Ben  
Transport:  1
Mileage:     100

Record 2:
Name:        Carly  
Transport:  2
Mileage:     150


Record 3:
Name:        Simon  
Transport:  1
Mileage:     200


Name: FINISH
[shows records 1 - 3]



PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

CONST   MAXRECORDS      =5;

VAR            MILES                  :ARRAY [1..MAXRECORDS] OF INTEGER;
            ALLOWANCE            :ARRAY [1..MAXRECORDS] OF REAL;
            SELECTION            :ARRAY [1..MAXRECORDS] OF INTEGER;
        NAME            :ARRAY [1..MAXRECORDS] OF STRING;
        LOOP            :INTEGER;
        INPUTNAME       :STRING;


    BEGIN

    LOOP :=0;
    REPEAT

    WRITELN;
    WRITELN('  =================================================');
    WRITELN('  =   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('  =   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('  =                                               =');
    WRITELN('  =                                               =');
    WRITELN('  =                          DATE:  23/11/2006    =');
    WRITELN('  =================================================');

    WRITELN;

            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
            READLN(INPUTNAME);

              If INPUTNAME <> 'FINISH' THEN;
                BEGIN
                    LOOP := LOOP + 1;
                    NAME[LOOP] := INPUTNAME;

                  CLRSCR;
                {S H O W   T R A N S P O R T   S E L E C T I O N   M E N U}
                  WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                  WRITELN;
                  WRITELN('   1    MOTORCYCLE');
                  WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                  WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                  WRITELN;

                WRITE('PLEASE ENTER ', NAME[LOOP]);
                WRITE('S METHOD OF TRANSPORT:> ');
                READ(SELECTION[LOOP]);

                {E N T E R   M I L E A G E   F O R   S E L E C T E D   T R A N S P O R T}
                WRITE('PLEASE ENTER MILEAGE:> ');
                READLN(MILES[LOOP]);
                IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                CLRSCR;
         END;

         UNTIL (NAME[LOOP]='FINISH') OR (LOOP = MaxRecords);



    { E N D   S Y S T E M    R E P O R T   S C R E E N}
    WRITELN;
    WRITELN('E N D     S Y S T E M     R E P O R T:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO MaxRecords DO
    BEGIN

         WRITELN('RECORD:  ', LOOP:3);
         WRITELN('NAME:      ',       NAME[LOOP]);

            IF (SELECTION[LOOP]=1) THEN WRITELN ('TRANSPORT: MOTORCYCLE ');
            IF (SELECTION[LOOP]=2) THEN WRITELN ('TRANSPORT: CAR WITH LESS THAN 1500 CC CAPACITY ');
            IF (SELECTION[LOOP]=3) THEN WRITELN ('TRANSPORT: CAR WITH MORE THAN 1500 CC CAPACITY ');

         WRITELN('MILEAGE:   ',     MILES[LOOP]);

         {WRITE THE ALLOWANCE USING THE POUND SIGN HEX CODE}
         WRITE('ALLOWANCE: ');
         WRITE(#156);
         WRITE( ALLOWANCE[LOOP]:4:2);
         WRITELN;
         WRITELN;
         END;

    WRITELN;
    WRITELN('PRESS ANY KEY TO CONTINUE...');
    READKEY;
end.
There it is:
              If INPUTNAME <> 'FINISH' THEN;
it should be
              If INPUTNAME <> 'FINISH' THEN
(;) character should not be entered after THEN statement.
Hey...
Just tried that  (Without  (  ;  )  after the THEN

and it shows the following screen:


WRITELN('  =================================================');
    WRITELN('  =   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('  =   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('  =                                               =');
    WRITELN('  =                                               =');
    WRITELN('  =                          DATE:  23/11/2006    =');
    WRITELN('  =================================================');

    WRITELN;

            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');


if i type FINISH there it loops on that screen.
The end system report screen is shown when the processed records meets the max record count.

here is ALL the code i am using...
may be that i have put a line of code in the wrong place.


*** CODE START ***

PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

CONST   MAXRECORDS      =5;

VAR            MILES                  :ARRAY [1..MAXRECORDS] OF INTEGER;
            ALLOWANCE            :ARRAY [1..MAXRECORDS] OF REAL;
            SELECTION            :ARRAY [1..MAXRECORDS] OF INTEGER;
        NAME            :ARRAY [1..MAXRECORDS] OF STRING;
        LOOP            :INTEGER;
        INPUTNAME       :STRING;


    BEGIN

    LOOP :=0;
    REPEAT

    WRITELN;
    WRITELN('  =================================================');
    WRITELN('  =   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('  =   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('  =                                               =');
    WRITELN('  =                                               =');
    WRITELN('  =                          DATE:  23/11/2006    =');
    WRITELN('  =================================================');

    WRITELN;

            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
            READLN(INPUTNAME);

              If INPUTNAME <> 'FINISH' THEN
                BEGIN
                    LOOP := LOOP + 1;
                    NAME[LOOP] := INPUTNAME;

                  CLRSCR;
                {S H O W   T R A N S P O R T   S E L E C T I O N   M E N U}
                  WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                  WRITELN;
                  WRITELN('   1    MOTORCYCLE');
                  WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                  WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                  WRITELN;

                WRITE('PLEASE ENTER ', NAME[LOOP]);
                WRITE('S METHOD OF TRANSPORT:> ');
                READ(SELECTION[LOOP]);

                {E N T E R   M I L E A G E   F O R   S E L E C T E D   T R A N S P O R T}
                WRITE('PLEASE ENTER MILEAGE:> ');
                READLN(MILES[LOOP]);
                IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                CLRSCR;
         END;

         UNTIL (NAME[LOOP]='FINISH') OR (LOOP = MaxRecords);



    { E N D   S Y S T E M    R E P O R T   S C R E E N}
    WRITELN;
    WRITELN('E N D     S Y S T E M     R E P O R T:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO MaxRecords DO
    BEGIN

         WRITELN('RECORD:  ', LOOP:3);
         WRITELN('NAME:      ',       NAME[LOOP]);

            IF (SELECTION[LOOP]=1) THEN WRITELN ('TRANSPORT: MOTORCYCLE ');
            IF (SELECTION[LOOP]=2) THEN WRITELN ('TRANSPORT: CAR WITH LESS THAN 1500 CC CAPACITY ');
            IF (SELECTION[LOOP]=3) THEN WRITELN ('TRANSPORT: CAR WITH MORE THAN 1500 CC CAPACITY ');

         WRITELN('MILEAGE:   ',     MILES[LOOP]);

         {WRITE THE ALLOWANCE USING THE POUND SIGN HEX CODE}
         WRITE('ALLOWANCE: ');
         WRITE(#156);
         WRITE( ALLOWANCE[LOOP]:4:2);
         WRITELN;
         WRITELN;
         END;

    WRITELN;
    WRITELN('PRESS ANY KEY TO CONTINUE...');
    READKEY;

end.

*** CODE END ***
That's because you are entering the FINISH word in the INPUTNAME variable.

            READLN(INPUTNAME);

              If INPUTNAME <> 'FINISH' THEN
                BEGIN
                    LOOP := LOOP + 1;
                    NAME[LOOP] := INPUTNAME;

If the word FINISH is entered the NAME[LOOP] never will be equal to FINISH, because the assignment "NAME[LOOP] := INPUTNAME" is after "If INPUTNAME <> 'FINISH' THEN". So you are checking wrong variable for the FINISH word in the loop control

         UNTIL (NAME[LOOP]='FINISH') OR (LOOP = MaxRecords);

You should use

         UNTIL (INPUTNAME='FINISH') OR (LOOP = MaxRecords);
Suggestion: Try entering FINISH as the first entry, and seeing if your loop terminates.
OK, For-Soft that correction to the code worked when i type finish it now comes up and shows the end system report... however say i type one full record into the program. Then enter 'FINISH' as the name, the end system report shows the record data i entered, then blank records after that  for example:


Record:      1
Name:        PAUL
Transport:  Motorcycle
Mileage:     500
Allowance: £75.00


Record:      2
Name:      
Mileage:  
Allowance:


Record:      3
Name:
Mileage:
Allowance:


...
[up to the max record value which is 5]

i was hoping for it to only show (in the example above)  Record 1 then not show anything else after that.

many thanks to all who have helped me with this, i apprecate the time effort and knowledge you are putting in to help me solve the issues raised by my program/programming.

Skulls.
I wrote it before. But, I can write it again:

"You should not process all MaxRecord loops at the "end report" program section. You should rather declare another counter and make a loop from 1 to LOOP. So, records in table equal and above the "FINISH" will not be processed during the "end report" generation"

    FOR LOOP:=1 TO MaxRecords DO

Currently, the loop prints all records, including those empty ones.
So have a loop within a loop?

i'm not sure i totally understand For-Soft.
Thank you for being patient with me. I am learning pascal but some things i struggle to comprehend.
No. You need to change the "FOR LOOP:=1 TO MaxRecords DO" loop to go from 1 to amount of entered records. Right now, it goes through all records, because the taget value for this loop is MaxRecords.
OH I SEE.....

so i would need something like...


CLRSCR;
    WRITELN;
    WRITELN('E N D     S Y S T E M     R E P O R T:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO Loop DO
    BEGIN


It will not work. It will make just one iteration, because LOOP variable will be equal to LOOP variable at the end of the loop.

You need to use different "counter" and "target" variables for a FOR statement to work correctly.
SO SOMETHING LIKE:
======================================

PROGRAM TASK3(INPUT,OUTPUT);
USES CRT;

CONST   MAXRECORDS      =10;

VAR            MILES                    :ARRAY [1..MAXRECORDS] OF INTEGER;
            ALLOWANCE              :ARRAY [1..MAXRECORDS] OF REAL;
            SELECTION         :ARRAY [1..MAXRECORDS] OF INTEGER;
        NAME              :ARRAY [1..MAXRECORDS] OF STRING;
        LOOP              :INTEGER;
        INPUTNAME         :STRING;
 

{NEW LOOP COUNTER FOR THE PROCESSED RECORDS}
LOOP2   :integer;



    BEGIN

    LOOP :=0;

{SET THE LOOP2 COUNTER AT ZERO}
   LOOP2 :=0;

    REPEAT

    WRITELN;
    WRITELN('  =================================================');
    WRITELN('  =   FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM    =');
    WRITELN('  =   DESIGNED BY:  BEN LACEY (20026111)          =');
    WRITELN('  =                                               =');
    WRITELN('  =                                               =');
    WRITELN('  =                          DATE:  23/11/2006    =');
    WRITELN('  =================================================');

    WRITELN;

            WRITE('ENTER THE NAME OF THE PERSON YOU WISH TO PROCESS:> ');
            READLN(INPUTNAME);

              If INPUTNAME <> 'FINISH' THEN
                BEGIN
                    LOOP := LOOP + 1;
                    NAME[LOOP] := INPUTNAME;

                  CLRSCR;
                {S H O W   T R A N S P O R T   S E L E C T I O N   M E N U}

             REPEAT
                  WRITELN('THE SYSTEM RECOGNISES THE FOLLOWING MEANS OF TRANSPORT:');
                  WRITELN;
                  WRITELN('   1    MOTORCYCLE');
                  WRITELN('   2    CAR WITH LESS THAN 1500 CC CAPACITY');
                  WRITELN('   3    CAR WITH MORE THAN 1500 CC CAPACITY');
                  WRITELN;

                WRITE('PLEASE ENTER ', NAME[LOOP]);
                WRITE('S METHOD OF TRANSPORT:> ');
                READ(SELECTION[LOOP]);

                         {TRANSPORT INPUT VALIDATION. WILL NOT ACCEPT A VALUE LESS THAN ONE OR MORE THAN 3.
                          THIS SHOWS AN ERROR MESSAGE. CLEARS THE SCREEN. THEN RETURNS TO THE TRANSPORT
                          SELECT SCREEN FOR THE USER TO RE-ENTER THEIR SELECTION}

                         IF (SELECTION[LOOP] < 1) OR (SELECTION[LOOP] > 3) THEN
                              BEGIN
                                 WRITELN;
                                 WRITELN('   YOU HAVE ENTERED AN INVALID SELECTION');
                                 WRITELN;
                                 READKEY;
                                 CLRSCR;
                              END;
                         UNTIL (SELECTION[LOOP] >= 1) AND (SELECTION[LOOP] <= 3);


                {E N T E R   M I L E A G E   F O R   S E L E C T E D   T R A N S P O R T}
                WRITE('PLEASE ENTER MILEAGE:> ');
                READLN(MILES[LOOP]);
                IF (SELECTION[LOOP]=1) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.15;
                IF (SELECTION[LOOP]=2) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.20;
                IF (SELECTION[LOOP]=3) THEN ALLOWANCE[LOOP]:=MILES[LOOP]*0.30;
                CLRSCR;
         END;

         UNTIL (INPUTNAME='FINISH') OR (LOOP = MaxRecords);


{SET THE LOOP INCRIMENT}
LOOP2 := LOOP2 + 1;


    { E N D   S Y S T E M    R E P O R T   S C R E E N}
    CLRSCR;
    WRITELN;
    WRITELN('E N D     S Y S T E M     R E P O R T:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO MAXRECORDS DO
    BEGIN

         WRITELN('RECORD:  ', LOOP:3);
         WRITELN('NAME:      ',       NAME[LOOP]);

            IF (SELECTION[LOOP]=1) THEN WRITELN ('TRANSPORT: MOTORCYCLE ');
            IF (SELECTION[LOOP]=2) THEN WRITELN ('TRANSPORT: CAR WITH LESS THAN 1500 CC CAPACITY ');
            IF (SELECTION[LOOP]=3) THEN WRITELN ('TRANSPORT: CAR WITH MORE THAN 1500 CC CAPACITY ');

         WRITELN('MILEAGE:   ',     MILES[LOOP]);

         {WRITE THE ALLOWANCE USING THE POUND SIGN HEX CODE}
         WRITE('ALLOWANCE: ');
         WRITE(#156);
         WRITE( ALLOWANCE[LOOP]:4:2);
         WRITELN;
         WRITELN;
         END;

    WRITELN;
    WRITELN('PRESS ANY KEY TO CONTINUE...');
    READKEY;

end.
You are trying to improve wrong loop. The data entering routine was working properly, isn't it.

The "end system report" loop is the one responsible for wrong end report printing.

    { E N D   S Y S T E M    R E P O R T   S C R E E N}
    CLRSCR;
    WRITELN;
    WRITELN('E N D     S Y S T E M     R E P O R T:');
    WRITELN('===========================================================================');
    WRITELN;
    FOR LOOP:=1 TO MAXRECORDS DO
I thought the initial LOOP:=0;   before the "FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM" screen was looping / counting the processed records.

Each FOR statement is looping the statement following it.

Basically there are two kinds of statements. Single and complex (compound). Both are ending with a semicolon (;).

Complex statement is all between begin and end words. Simple statement is just one line ending with a semicolon.

FOR LOOP:=0 to 10 DO Write (LOOP);

makes a loop doing the Write statement.

FOR LOOP:=0 to 10 DO
 begin
 
 end;

Will loop all statements between begin and end words.
 And the thing to remember about "for" loops is that they will be executed the specified number of times.

In each of the statements (immediately) above, the "Write( LOOP );" and the contents of  the "begin end" will be executed how many times?

  See if you can tell, without having the computer do it for you... :-)
begin -> end   will loop once

and write(loop);  will loop for a predefined amount of times?
The "begin   end"  is considered a compound statement, and will be executed the "predefined amount of time", as will the "write(loop)"

To see how many times it (the statement) is executed, execute the following program:

begin LoopTest( input, output );

var
  loop : integer;

begin
  for loop := 0 to 10 do
    writeln( loop );
end.
--------------------------------------------------
The output will be:
--------------------------------------------------
0
1
2
3
4
5
6
7
8
9
10
--------------------------------------------------
sigh... that should have been:

program LoopTest( input, output );

Sorry.
Wow, you certainly getting quite an education out of this question, aren't you... :-)
The reason that I brought up the comment about the for loop was to get you to think about the one you have in your program.
The (last) one you have in your program is:

  FOR LOOP:=1 TO MAXRECORDS DO
    BEGIN
      ...
    END;

How many times will this loop be executed?
How many times SHOULD it be executed?
YAAAAAY!!! I DONE IT!

i set another loop called "counter"

set it to 0
then at the end of each record's data input set it to incriment then put

for loop:=1 to counter do
  ...
  ...


I'm pleased with myself now! it finally clicked  :-D
thank you!
ok i am going to share the points out as follows:

For-Soft for all your dedicated help and support:  100
HonorGod for the support you have given         :   60

if you do not agree with this grading please post here and we can agree on grading amendments if you feel they are justified

(This way it saves the administrators hassle of changing the points!)
I don't agree... I should Get ALL THE PONIKS!!!
Just Kidding... :)
You saw your mistake... GimmyPoinks!!! :)
Thanks, and good luck in your further programming.
Thank you HonorGod
and thank you to all with your help on this topic.

It has certinally helped my understanding and boosted my knowledge. PAscal has intrigued me so much so that i am moving on to learn about Python!

:-P


Similar interface as pascal. and it is still command line.
Bye for now!


Skulls.