Re: [問題] C++問題
※ 引述《hankhank5345 (MPower)》之銘言:
: 這題小弟想很久但還是不會用function來寫,請問誰可以幫個忙?
: write a function that has an double as a parameter
: and returns a double through the function call.
: The parameter is the income for a single person and
: the return value is the amount of income tax owed.
: Use the "Schedule X- single" table below.
: Write a main function to test the function you have written.
: You are REQUIRED to use nested if... else if....else if.....else
: to determain the caluclation to use for the tax.
: Schedule X- Single
: If taxable But not over The Tax is
: income is
: Over--
: $0 $7550 10% of the amount over $0
: $7550 $30650 $755 plus 15% of the amount over 7550
: $30650 $74200 $4220.00 plus 25% of the amount over 30650
: $74200 $154800 $15107.50 plus 28% of the amount over 74200
: $154800 $336550 $37657.50 plus 33% of the amount over 154800
: $336550 $ no limit $97653.00 plus 35% of the amount over 336550
double tax(double income)
{
double result = 0.0;
if(income >= 0 && income < 7550){
result = income * 0.1;
}
if(income >= 7550 && income < 30650){
result = 755 + (income - 7550) * 0.15;
}
// rest cases
return result;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.207.94
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章