D
Derek Zoolander
can anyone do this ?
A TaxPayer has a name, a yearly salary and a tax credit (both
floating-point
values).
The amount of tax paid by a TaxPayer is calculated as follows. 20% is
paid on
the first =E2=82=AC34,000 and 41% is paid on the remainder (if any). Fina=
lly,
the tax credit
is deducted from this amount, but this cannot of course reduce the tax
to less than
zero. For example, if John has a salary of =E2=82=AC60,000 and a tax cred=
it of
=E2=82=AC5,000, his
total tax is calculated as follows:
20% of =E2=82=AC34,000: +=E2=82=AC 6,800
41% of (=E2=82=AC60,000 =E2=80=93 34,000): +=E2=82=AC 10,660
deduct tax credit: -=E2=82=AC 5,000
Total tax due: =E2=82=AC 12,460
Implement in Ruby the TaxPayer class, implementing whichever methods you
deem appropriate. Using this class, write a script that reads a name,
salary and tax
credit from a file called =E2=80=9Ctaxpayer.dat=E2=80=9D, and uses this d=
ata to create a
TaxPayer
object. Finally, the name and total tax due from this Taxpayer object
should be
printed to the screen.
A sample =E2=80=9Ctaxpayer.dat=E2=80=9D input file for the above example =
would be:
John
60000
5000
(
thanks
-- =
Posted via http://www.ruby-forum.com/.=
A TaxPayer has a name, a yearly salary and a tax credit (both
floating-point
values).
The amount of tax paid by a TaxPayer is calculated as follows. 20% is
paid on
the first =E2=82=AC34,000 and 41% is paid on the remainder (if any). Fina=
lly,
the tax credit
is deducted from this amount, but this cannot of course reduce the tax
to less than
zero. For example, if John has a salary of =E2=82=AC60,000 and a tax cred=
it of
=E2=82=AC5,000, his
total tax is calculated as follows:
20% of =E2=82=AC34,000: +=E2=82=AC 6,800
41% of (=E2=82=AC60,000 =E2=80=93 34,000): +=E2=82=AC 10,660
deduct tax credit: -=E2=82=AC 5,000
Total tax due: =E2=82=AC 12,460
Implement in Ruby the TaxPayer class, implementing whichever methods you
deem appropriate. Using this class, write a script that reads a name,
salary and tax
credit from a file called =E2=80=9Ctaxpayer.dat=E2=80=9D, and uses this d=
ata to create a
TaxPayer
object. Finally, the name and total tax due from this Taxpayer object
should be
printed to the screen.
A sample =E2=80=9Ctaxpayer.dat=E2=80=9D input file for the above example =
would be:
John
60000
5000
(
thanks
-- =
Posted via http://www.ruby-forum.com/.=