中四CIT問題(programming)

2007-10-20 5:39 pm

回答 (1)

2007-10-20 9:05 pm
✔ 最佳答案
program cal_tax;
var name:string;
var nchild,nparent:integer;
var income,totalallow:longint;
var chargeincome,tax:real;
var mstatus:char;
begin
write('Name?');
readln(name);
write('Total annual income?');
readln(income);
write('Marital status(M=married,S=single)?');
readln(mstatus);
write('Number of children?');
readln(nchild);
write('Number of dependent parents?');
readln(nparent);
totalallow:=30000;
if mstatus = 'M'
then totalallow:=totalallow+30000;
if (nchild > 0) and (nchild <= 5 )
then totalallow:=totalallow+(10000*nchild);
if (nparent > 0) and (nparent <= 4)
then totalallow:=totalallow+(15000*nparent);

chargeincome:=income-totalallow;
tax:=0;
if chargeincome >= 20000
then begin
tax:=tax+2000;
if (chargeincome-20000) >= 20000
then tax:=tax+4000
else tax:=tax+(chargeincome-20000)/5;
if (chargeincome-40000) > 0
then tax:=6000+(chargeincome-40000)*0.3
end
else tax:=chargeincome/10;
if tax >= (chargeincome/4)
then tax:=income/4;
if tax < 0
then tax:=0;
writeln('Tax for ',name,' is $',tax:0:0);
readln
end.

2007-10-20 13:11:13 補充:
if chargeincome < 0then tax:=0;上面段野加係下面兩句既中間then tax:=income/4;if tax < 0
參考: ME


收錄日期: 2021-04-13 18:44:34
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20071020000051KK00886

檢視 Wayback Machine 備份