⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 税收计算.cpp

📁 五种排序算法
💻 CPP
字号:
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

bool f_input(float * arr);

int main()
{
    float income,tax;
    cout<<"enter your earning:";
    while (f_input(&income))
    {

        tax=0;
        if (income>35000)
        {
            tax=(income-35000)*0.20;
            income=35000;
        }
        if (income>15000)
        {
            tax=tax+(income-15000)*0.15;
            income=15000;
        }
        if (income>5000)
        {
            tax=tax+(income-5000)*0.10;
        }
        if (income<=5000)
            cout<<"you earning too little,so no ratepaying.\n";
        cout<<"the tax you should paying:"<<tax<<endl;
    }
    cout<<"bad input, will quit!";
    for (int i=0;i<500000000;i++) ;
}

bool f_input(float * arr)
{
    char f_char[24];
    int num_of_dot,index;

    num_of_dot=0;
    index=0;
    gets(f_char);

    while (f_char[index]!='\0')
    {
        if ((f_char[index]!='.')&&!isdigit(f_char[index]))
            return false;
        if (f_char[index]=='.')
            num_of_dot++;
        index++;
    }
    if (num_of_dot>1)
        return false;
    else
    {
        *arr=atof(f_char);
        return true;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -