I need some help calculating taxes

I am trying to make a program that calculates tax at 19.5% for the first $728.77 of an employee's weekly income. It has to deduct 33% of everything above $728.77 but below $1150.68
And it has to deduct 39% from anything above $1150.68

This is what Iv'e come up with so far, could anyone plz give me a hand here and there?

[code]

uses
crt;

const
normalhours = 40;
taxrate1 = 0.195;
taxrate2 = 0.33;

var
empname : string[20];
payrate , errorcode : real;
workedhours , errorcode2 : real;
amountpaid , overtimehours , premiumhours , paidhours : real;
taxdeduction1 , taxdeduction2 : real;

begin
clrscr;
write('Enter your name: ');
readln(empname);

repeat
write('Enter the hourly pay rate: ');
{$I-}
readln(payrate);
{$I+}
errorcode := IOResult;
if errorcode <> 0 then
begin
sound(1000);
delay(100);
nosound;
end;
until errorcode = 0;

repeat
write('Enter the hours worked this week: ');
{$I-}
readln(workedhours);
{$I+}
errorcode := IOResult;
if errorcode <> 0 then
begin
sound(1000);
delay(100);
nosound;
end;
until errorcode = 0;
writeln;

overtimehours := workedhours - normalhours;
if overtimehours <= 0 then
begin
paidhours := workedhours;
end
else if overtimehours > 0 then
begin
premiumhours := overtimehours * payrate * 1.5;
end;

paidhours := normalhours * payrate;
amountpaid := premiumhours + paidhours;

taxdeduction1 := amountpaid * taxrate1;

taxdeduction2 := amountpaid * taxrate2;

writeln('Current employee is: ', empname);
writeln('Employee hourly pay rate is: $', payrate:2:2);
writeln('The hours the employee worked this week is: ', workedhours:2:2);
writeln('Employee grosspay for this week is: $', amountpaid:2:2);
writeln;
writeln('Employee tax deduction at 19.5% is: S', taxdeduction1:2:2);
writeln('Current employee net pay is: S', amountpaid - taxdeduction1:2:2);
writeln('Employee tax deduction at 33% is: S', taxdeduction2:2:2);
writeln('Press ENTER to exit the program');
readln;
end.
[/code]

Comments

  • : I am trying to make a program that calculates tax at 19.5% for the first $728.77 of an employee's weekly income. It has to deduct 33% of everything above $728.77 but below $1150.68
    : And it has to deduct 39% from anything above $1150.68
    :
    : This is what Iv'e come up with so far, could anyone plz give me a hand here and there?
    :
    : [code]
    :
    : uses
    : crt;
    :
    : const
    : normalhours = 40;
    : taxrate1 = 0.195;
    : taxrate2 = 0.33;
    :
    : var
    : empname : string[20];
    : payrate , errorcode : real;
    : workedhours , errorcode2 : real;
    : amountpaid , overtimehours , premiumhours , paidhours : real;
    : taxdeduction1 , taxdeduction2 : real;
    :
    : begin
    : clrscr;
    : write('Enter your name: ');
    : readln(empname);
    :
    : repeat
    : write('Enter the hourly pay rate: ');
    : {$I-}
    : readln(payrate);
    : {$I+}
    : errorcode := IOResult;
    : if errorcode <> 0 then
    : begin
    : sound(1000);
    : delay(100);
    : nosound;
    : end;
    : until errorcode = 0;
    :
    : repeat
    : write('Enter the hours worked this week: ');
    : {$I-}
    : readln(workedhours);
    : {$I+}
    : errorcode := IOResult;
    : if errorcode <> 0 then
    : begin
    : sound(1000);
    : delay(100);
    : nosound;
    : end;
    : until errorcode = 0;
    : writeln;
    :
    : overtimehours := workedhours - normalhours;
    : if overtimehours <= 0 then
    : begin
    : paidhours := workedhours;
    : end
    : else if overtimehours > 0 then
    : begin
    : premiumhours := overtimehours * payrate * 1.5;
    : end;
    :
    : paidhours := normalhours * payrate;
    : amountpaid := premiumhours + paidhours;
    :
    : taxdeduction1 := amountpaid * taxrate1;
    :
    : taxdeduction2 := amountpaid * taxrate2;
    :
    : writeln('Current employee is: ', empname);
    : writeln('Employee hourly pay rate is: $', payrate:2:2);
    : writeln('The hours the employee worked this week is: ', workedhours:2:2);
    : writeln('Employee grosspay for this week is: $', amountpaid:2:2);
    : writeln;
    : writeln('Employee tax deduction at 19.5% is: S', taxdeduction1:2:2);
    : writeln('Current employee net pay is: S', amountpaid - taxdeduction1:2:2);
    : writeln('Employee tax deduction at 33% is: S', taxdeduction2:2:2);
    : writeln('Press ENTER to exit the program');
    : readln;
    : end.
    : [/code]
    :
    First you need to check if the employee is paid more than $728.77. If he has you deduct the taxes over that amount, else you deduct the taxes over the amount he has been payed:
    [code]
    if amountpaid <= 728.77 then
    taxdeduction := amountpaid * taxrate1
    else
    begin
    taxdeduction := 728.77 * taxrate1;
    end;
    [/code]
    If he has been paid more than 728.77, then you need to check if he has been paid more than $1150.68. This forms a similar if-then statement as before. This amount is added to the taxdeduction.
    [code]
    if amountpaid <= 728.77 then
    taxdeduction := amountpaid * taxrate1
    else
    begin
    taxdeduction := 728.77 * taxrate1;
    if amountpaid <= 1150.68 then
    taxdeduction := taxdeduction + (amountpaid - 728.77) * taxrate2
    else
    begin
    taxdeduction := taxdeduction + (1150.68 - 728.77) * taxrate2;
    taxdeduction := taxdeduction + (amountpaid - 1150.68) * taxrate3;
    end;
    end;
    [/code]
    And the taxes for everything over the $1150.68 is also added to the taxdeduction.
Sign In or Register to comment.

Howdy, Stranger!

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

Categories

In this Discussion