C++ primer plus 6th 第六章6.5编程题参考答案


#include <iostream>
const float class1=5000;
const float class2=10000;
const float class3=20000;
const float tax1=0;
const float tax2=0.1;
const float tax3=0.15;
const float tax4=0.2;
int main() {
    using namespace std;
    float tax;
    float income;
    cout<<"Enter your income:";
    while(cin>>income&&income>=0)
    {
        if(income<=class1)
            tax=income*tax1;
        else if(income<=class2)
            tax=(income-class1)*tax2;
        else if(income<=class3)
            tax=class2*tax2+(income-class2-class1)*tax3;
        else
            tax=class2*tax2+class3*tax3+(income-class3-class2-class1)*tax4;
        cout<<"Your tax owed is: "<<tax<<" tvarps."<<endl;
        cout<<"Next case,enter your income:";
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值