Re: [問題] C++問題

看板C_and_CPP作者 (pony)時間15年前 (2009/02/20 07:58), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《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
文章代碼(AID): #19dV8uDX (C_and_CPP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
問題
3
7
文章代碼(AID): #19dV8uDX (C_and_CPP)