📄 taxfile.cpp
字号:
// TaxFile.cpp
#include <iomanip>
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
#include <fstream>
using std::ifstream;
using std::ofstream;
// ---函数 CalculateTax() 的宣告----
float CalculateTax(float);
// ---主程式------------------------
int main()
{
char* FileNameIn = "Income.txt";
char* FileNameOut = "Tax.txt";
float Income, Tax;
ifstream FileInput;
ofstream FileOutput;
FileInput.open( FileNameIn );
FileOutput.open( FileNameOut );
if (!FileInput)
{cout << "档案: " << FileNameIn
<< " 开启失败!" << endl; exit(1);}
if (!FileOutput)
{cout << "档案: " << FileNameOut
<< " 存档失败!" << endl; exit(1);}
FileInput >> Income;
Tax = CalculateTax(Income);
cout << "您要缴的综合所得税是: "
<< Tax << " 元";
FileOutput << "您要缴的综合所得税是: "
<< Tax << " 元";
FileInput.close();
FileOutput.close();
return 0;
}
// ---函数 CalculateTax() 的定义-----
float CalculateTax(float GIncome)
{
float Tax;
if (GIncome < 0.0)
cout << "您输入的综合所得净额没有意义!\n";
else if (GIncome < 330000.0)
Tax = GIncome * 0.06;
else if (GIncome < 890000.0)
Tax = GIncome * 0.13 - 23100;
else if (GIncome < 1780000.0)
Tax = GIncome * 0.21 - 94300;
else if (GIncome < 3340000.0)
Tax = GIncome * 0.3 - 254500;
else
Tax = GIncome * 0.4 - 588500;
return Tax;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -