Solved

Creating a program to store text in an array

Posted on 2006-11-26
59
416 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:seraph_matrix_631
  • 22
  • 19
  • 8
  • +2
59 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 18014310
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
0
 
LVL 41

Assisted Solution

by:HonorGod
HonorGod earned 60 total points
ID: 18014589
mlmcc is absolutely correct.

We will, however, comment on any code that you provide, and point you in the right direction.

So, what do you have so far?
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18020088
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?
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18026583
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
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18026934
- 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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18027515
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)
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18033925
For-Soft ... I am sorry but that went straight over my head!!
Please could you explain that using less Jargon please?

Much Appreciated!
Skulls  :-)
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18034854
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18039475
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18040038
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18040746
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18041055
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.

0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18045025
so what code can i use to do this?
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18045130
Const MaxRecords=500;

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

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

var DataRecordArray: ADataRecordsArray;
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18048447
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.
0
 
LVL 10

Accepted Solution

by:
For-Soft earned 100 total points
ID: 18048680
the FOR loop is not a good choice of the repetitive statement in this case. You need a repetitive statement capable of testing strings for values. You should consider a WHILE or REPEAT statements, then.

Also, you tend to write the same code over and over again. Wouldn't it be simpler to do it this way:

  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;

or this way:

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

Or you can make an array with all used factors:

CONST FactorsArray: array [1..3] of Real = (0.15,0.20,0.30);

  WRITE('PLEASE ENTER MILEAGE:> ');
  READLN(MILES[LOOP]);
  ALLOWANCE[LOOP]:=MILES[LOOP]*FactorsArray[SELECTION[LOOP]];
  CLRSCR;
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18050329
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18052176
"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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18065117
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.
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18065337
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
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18066806
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18081245
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18081391
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
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18083282
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18084845
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
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18085557
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;

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18085982
Looks good.  Couldn't remember if Pascal provided a function or not.

mlmcc
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18086490
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.
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 18087802
Strings.tpu

  StrUpper




uses
  strings;

var
  s: string;

begin
  s:='hello';
  writeLn(s);
  strupper(@(s));
  writeLn(s)
end.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18095863
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!
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18107662
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18108046
There it is:
              If INPUTNAME <> 'FINISH' THEN;
it should be
              If INPUTNAME <> 'FINISH' THEN
(;) character should not be entered after THEN statement.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18108618
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 ***
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18108675
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);
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18109345
Suggestion: Try entering FINISH as the first entry, and seeing if your loop terminates.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18110602
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18110631
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18110666
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18110709
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18110721
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


0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18110755
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.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18110839
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.
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18110961
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
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18111311
I thought the initial LOOP:=0;   before the "FIT-2-DROP EMPLOYEE REMUNERATION PROGRAM" screen was looping / counting the processed records.

0
 
LVL 10

Expert Comment

by:For-Soft
ID: 18111355
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.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18112261
 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... :-)
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18112387
begin -> end   will loop once

and write(loop);  will loop for a predefined amount of times?
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18112472
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
--------------------------------------------------
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18112475
sigh... that should have been:

program LoopTest( input, output );

Sorry.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18112477
Wow, you certainly getting quite an education out of this question, aren't you... :-)
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18112703
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?
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18116676
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!
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18116961
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!)
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 18118241
I don't agree... I should Get ALL THE PONIKS!!!
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 18118245
Just Kidding... :)
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 18152677
You saw your mistake... GimmyPoinks!!! :)
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18155015
Thanks, and good luck in your further programming.
0
 
LVL 1

Author Comment

by:seraph_matrix_631
ID: 18156183
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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now