Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
URgent help needed Posted by djvenom on 18 Jan 2012 at 5:37 PM
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.
Report
Re: URgent help needed Posted by Actor on 18 Jan 2012 at 7:44 PM
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 ID is the social security number then you only need declare it as string[9]. For name you can probably get along with string[30]. Likewise for Health_Ins and position.

Good luck.


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[30];  
   position:array[1..65]of string[30];
   name:array[1..65]of string[30];
   ID:array[1..65] of string[9];
   count:integer;

Report
Re: URgent help needed Posted by djvenom on 19 Jan 2012 at 12:13 AM
: 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
: ID is the social security number then you only need declare
: it as string[9]. For name you can
: probably get along with string[30]. Likewise
: for Health_Ins and position.
:
: Good luck.
:
:
:
: 
: 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[30];  
:    position:array[1..65]of string[30];
:    name:array[1..65]of string[30];
:    ID:array[1..65] of string[9];
:    count:integer;
: 
:
:


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?
Report
Re: URgent help needed Posted by Actor on 19 Jan 2012 at 10:09 AM

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

I take it you are not getting an error on line 16?



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.