URgent help needed - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

URgent help needed

djvenomdjvenom Posts: 2Member
URGENT PROJEct help needed, first time attempting Pascal please help.

Develop a pascal programm that input employee ID , name, the health institution, of each employee , their position and their gross salary. Calculate each employee's total deductions and their net salary using the following information:

Deductions or tax are calculated as follows:

PAYE: 15% of salary that is above 30,000, otherwise its 8% for salary below 30,000

NIS: 3% of salary for all employees

NHT: 4% for salary less than 25,000 and 5% for gross greater than or equal to 25,000

Print each emploees ID , Name , Gross Salary , Total Deduction and Net Salary.


Heres what i tried so far but have a syntax error and cant fix:


Program salaries;
Var
gross_sal:array[1..65]of real;
PAYE:real;
NIS:real;
NHT:real;
Total_ded:array[1..65] of real;
Net_sal:array[1..65] of real;
Health_Ins:array[1..65] of string;
position:array[1..65]of string;
name:array[1..65]of string;
ID:array[1..65] of string;
count:integer;
Begin
writeln('A program that accepts employee Health_Ins,position,gross_sal,ID,name.Calculate and output each name,ID, gross_sal,Total_ded and Net_sal');
For count:=1 to 65 do;
Begin
Write ('Enter employee ID');
Read (ID[count]);
Write ('Enter employee name');
Read (name[count]);
Write ('Enter the Health_Ins of employee');
Read (Health_Ins[count]);
Write ('Enter the position of employee');
Read (position[count]);
Write ('Enter the gross_sal of employee');
Read (gross_sal[count]);
IF gross_sal[count]>30000 THEN
PAYE:=0.15*gross_sal[count]
ELSE
PAYE:=0.08*gross_sal[count];
NIS:=0.03*gross_sal[count];
IF (gross_sal[count]<25000) THEN
NHT:=0.04*gross_sal[count]
ELSE
NHT:=0.05*gross_sal[count];
Total_ded[count]:=PAYE+NHT+NIS;
Net_sal[count]:=gross_sal[count] - Total_ded[count];
End;
count:=1;
While count<=65 do
Begin
Write ('employee ID is,'ID[count]);
Write ('gross_salary is,'gross_sal[count]);
Write ('Total_ded is,'Total_ded[count]);
Write ('Net_sal is,'Net_sal[count]);
Write ('employee name is,'name[count]);
count:=count+1;
End;
Readln;
End.

Comments

  • ActorActor Posts: 438Member
    You are using up all your memory. You are trying to hold all the information for 65 employees in memory at once. Write the program so that you are dealing with data for only one employee at a time.

    If you must have all that data in memory at one time then try reducing the size of the strings. A string takes up 256 bytes. An array [1 .. 65] or string takes up 16640 bytes, about a quarter available for Turbo Pascal.

    None of these seven variables really needs 256 bytes of memory. If [b]ID[/b] is the social security number then you only need declare it as [b]string[leftbr]9[rightbr][/b]. For [b]name[/b] you can probably get along with [b]string[leftbr]30[rightbr][/b]. Likewise for [b]Health_Ins[/b] and [b]position[/b].

    Good luck.


    [code]
    Var
    gross_sal:array[1..65]of real;
    PAYE:real;
    NIS:real;
    NHT:real;
    Total_ded:array[1..65] of real;
    Net_sal:array[1..65] of real;
    Health_Ins:array[1..65] of [red]string[30][/red];
    position:array[1..65]of [red]string[30][/red];
    name:array[1..65]of [red]string[30][/red];
    ID:array[1..65] of [red]string[9][/red];
    count:integer;
    [/code]
  • djvenomdjvenom Posts: 2Member
    : You are using up all your memory. You are trying to hold all the
    : information for 65 employees in memory at once. Write the program
    : so that you are dealing with data for only one employee at a time.
    :
    : If you must have all that data in memory at one time then try
    : reducing the size of the strings. A string takes up 256 bytes. An
    : array [1 .. 65] or string takes up 16640 bytes, about a quarter
    : available for Turbo Pascal.
    :
    : None of these seven variables really needs 256 bytes of memory. If
    : [b]ID[/b] is the social security number then you only need declare
    : it as [b]string[leftbr]9[rightbr][/b]. For [b]name[/b] you can
    : probably get along with [b]string[leftbr]30[rightbr][/b]. Likewise
    : for [b]Health_Ins[/b] and [b]position[/b].
    :
    : Good luck.
    :
    :
    : [code]:
    : Var
    : gross_sal:array[1..65]of real;
    : PAYE:real;
    : NIS:real;
    : NHT:real;
    : Total_ded:array[1..65] of real;
    : Net_sal:array[1..65] of real;
    : Health_Ins:array[1..65] of [red]string[30][/red];
    : position:array[1..65]of [red]string[30][/red];
    : name:array[1..65]of [red]string[30][/red];
    : ID:array[1..65] of [red]string[9][/red];
    : count:integer;
    : [/code]:
    :


    Hey thanks for the quick response really appreciate it but could this be the reason for syntax error at line 44? Where the output statements are?
  • ActorActor Posts: 438Member

    You need a comma after the single quote, not before it.

    I take it you are not getting an error on line 16?
Sign In or Register to comment.