#include <iostream>
using namespace std;
int main()
{
// Prompt the user to enter filing status
cout << "Enter the filing status\n" << "(0-single filer, 1-married jointly,\n"
<< "2-married separately, 3-head of household): ";
int status;
cin >> status;
if (status < 0 || status > 3)
{
cout << "Wrong filing status";
return 0;
}
// Prompt the user to enter taxable income
cout << "Enter the taxable income: ";
double income;
cin >> income;
// Compute tax
double tax = 0;
if (status == 0)
{
// Compute tax for single filers
if (income <= 6000)
tax = income * 0.10;
else if (income <= 27950)
tax = 6000 * 0.10 + (income - 6000) * 0.15;
else if (income <= 67700)
tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (income - 27950) * 0.27;
else if (income <= 141250)
tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950) * 0.27 + (income - 67700) * 0.30;
else if (income <= 307050)
tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950) * 0.27 + (141250 - 67700) * 0.30 + (income - 141250) * 0.35;
else
tax = 6000 * 0.10 + (27950 - 6000) * 0.15 + (67700 - 27950) * 0.27 + (141250 - 67700) * 0.30 + (307050 - 141250) * 0.35
+ (income - 307050) * 0.386;
}
else if (status == 1)
{ // Compute tax for married file jointly
if (income <= 12000)
tax = income * 0.10;
else if (income <= 46700)
tax = 12000 * 0.10 + (income - 12000) * 0.15;
else if (income <= 112850)
tax = 12000 * 0.10 + (46700 - 12000) * 0.15 + (income - 46700) * 0.27;
else if (income <= 171950)
tax = 12000 * 0.10 + (46700 - 12000) * 0.15 + (112850 - 46700) * 0.27 + (income - 112850) * 0.30;
else if (income <= 307050)
tax = 12000 * 0.10 + (46700 - 12000) * 0.15 + (112850 - 46700) * 0.27 + (171950 - 112850) * 0.30
+ (income - 171950) * 0.35;
else
tax = 12000 * 0.10 + (46700 - 12000) * 0.15 + (112850 - 46700) * 0.27 + (171950 - 112850) * 0.30 + (307050 - 171950)
* 0.35 + (income - 307050) * 0.386;
}
else if (status == 2)
{ // Compute tax for married separately
if (income <= 6000)
tax = income * 0.10;
else if (income <= 23350)
tax = 6000 * 0.10 + (income - 6000) * 0.15;
else if (income <= 56425)
tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (income - 23350) * 0.27;
else if (income <= 85975)
tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350) * 0.27 + (income - 56425) * 0.30;
else if (income <= 153525)
tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350) * 0.27 + (85975 - 56425) * 0.30 + (income - 85975) * 0.35;
else
tax = 6000 * 0.10 + (23350 - 6000) * 0.15 + (56425 - 23350) * 0.27 + (85975 - 56425) * 0.30 + (153525 - 85975) * 0.35
+ (income - 153525) * 0.386;
}
else if (status == 3)
{ // Compute tax for head of household
if (income <= 10000)
tax = income * 0.10;
else if (income <= 37450)
tax = 10000 * 0.10 + (income - 10000) * 0.15;
else if (income <= 96700)
tax = 10000 * 0.10 + (37450 - 10000) * 0.15 + (income - 37450) * 0.27;
else if (income <= 156600)
tax = 10000 * 0.10 + (37450 - 10000) * 0.15 + (96700 - 37450) * 0.27 + (income - 96700) * 0.30;
else if (income <= 307050)
tax = 10000 * 0.10 + (37450 - 10000) * 0.15 + (96700 - 37450) * 0.27 + (156600 - 96700) * 0.30
+ (income - 156600) * 0.35;
else
tax = 10000 * 0.10 + (37450 - 10000) * 0.15 + (96700 - 37450) * 0.27 + (156600 - 96700) * 0.30 + (307050 - 156600)
* 0.35 + (income - 307050) * 0.386;
}
// Display the result
cout << "Tax is " << static_cast < int > (tax * 100) / 100.0 << endl;
return (0);
}
没有合适的资源?快使用搜索试试~ 我知道了~
C++程序设计(Y.Daniel Liang著) 答案部分1
共70个文件
cpp:70个
5星 · 超过95%的资源 需积分: 48 118 下载量 171 浏览量
2010-03-04
23:19:12
上传
评论 17
收藏 25KB RAR 举报
温馨提示
Y.Daniel Liang教授的经典教材答案,课后习题的完整解答
资源推荐
资源详情
资源评论
收起资源包目录
c++部分答案.rar (70个子文件)
Exercise3_7.cpp 4KB
Exercise5_5.cpp 636B
Exercise6_5.cpp 549B
Exercise7_13.cpp 845B
Exercise4_23.cpp 346B
Exercise4_11.cpp 302B
Exercise4_3.cpp 437B
Exercise5_3.cpp 228B
Exercise8_9.cpp 568B
Exercise7_1.cpp 505B
Exercise2_5.cpp 356B
Exercise2_3.cpp 217B
Exercise7_15.cpp 949B
Exercise7_7.cpp 808B
Exercise8_15.cpp 386B
Exercise4_9.cpp 675B
Exercise6_1.cpp 522B
Exercise5_19.cpp 364B
Exercise7_5.cpp 353B
Exercise5_23.cpp 541B
Exercise4_13.cpp 204B
Exercise6_13.cpp 925B
Exercise5_17.cpp 319B
Exercise3_9.cpp 838B
Exercise6_17.cpp 342B
Exercise8_7.cpp 398B
Exercise6_23.cpp 998B
Exercise8_5.cpp 275B
Exercise7_19.cpp 2KB
Exercise2_9.cpp 522B
Exercise6_11.cpp 2KB
Exercise4_19.cpp 1KB
Exercise3_5.cpp 568B
Exercise2_7.cpp 277B
Exercise5_9.cpp 815B
Exercise3_1.cpp 455B
Exercise7_3.cpp 489B
Exercise8_3.cpp 420B
Exercise3_3.cpp 773B
Exercise2_11.cpp 457B
Exercise4_25.cpp 460B
Exercise5_7.cpp 757B
Exercise4_5.cpp 654B
Exercise7_9.cpp 512B
Exercise5_1.cpp 396B
Exercise5_21.cpp 385B
Exercise6_15.cpp 1KB
Exercise8_13.cpp 321B
Exercise8_17.cpp 1017B
Exercise2_1.cpp 250B
Exercise5_15.cpp 2KB
Exercise7_17.cpp 673B
Exercise4_29.cpp 2KB
Exercise6_7.cpp 353B
Exercise4_7.cpp 223B
Exercise7_11.cpp 314B
Exercise5_11.cpp 708B
Exercise4_15.cpp 440B
Exercise5_13.cpp 348B
Exercise4_17.cpp 801B
Exercise4_27.cpp 274B
Exercise4_1.cpp 1KB
Exercise6_25.cpp 2KB
Exercise6_3.cpp 316B
Exercise4_21.cpp 1KB
Exercise6_21.cpp 1KB
Exercise8_11.cpp 258B
Exercise6_19.cpp 3KB
Exercise8_1.cpp 392B
Exercise6_9.cpp 326B
共 70 条
- 1
lusanqian
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页