?? tax.cpp
字號:
//#include <afx.h>
//#include <iostream.h>
//#include <fstream.h>
#include "employeestruct.h"
#include "calcclass.h"
#include <fstream>
#include <iostream>
using namespace std;
void operate_debuger(int debug_number)
{
switch (debug_number)
{
case 9:
cout <<"打開文件失敗!"<<endl;
case 7:
cout <<"Pay所得稅計算錯誤!"<<endl;
case 5:
cout <<"Income所得稅計算錯誤!"<<endl;
}
}
void main()
{
int operate_debug=0,linenumber=0,linecounter=1;
double alltax=0;
char filename[256];
cout <<"請輸入數據文件名:";
cin >>filename;
char buffer[256] = {0};
ifstream datafile("test.txt");
if(!datafile)
{
cerr << "unable to open file"
<<filename<<'\n';
operate_debug=9;
exit(-1);
}
datafile.getline(buffer,256, '\n');
sscanf(buffer,"%d",&linenumber);
while(true)
{
char buffer2[256]={0};
datafile.getline(buffer2,256, '\n');
if(linecounter>linenumber)
break;
else
{
employee * current_employee = new employee;
calc tax;
char sztemp[256]={0},sztemp1[256]={0};
int item=0;
sscanf(buffer2,"%s %d %s %d",sztemp,&(current_employee->number),
sztemp1,&item);
current_employee->mmdd = sztemp1;
current_employee->money = static_cast<float>(item);
switch (buffer2[0])
{case 112:
{
alltax+=tax.calctax(0,current_employee->money);
current_employee->tax=tax.calctax(0,current_employee->money);
if (current_employee->tax==-2)
operate_debug=7;
}
case 80:
{
alltax+=tax.calctax(0,current_employee->money);
current_employee->tax=tax.calctax(0,current_employee->money);
if (current_employee->tax==-2)
operate_debug=7;
}
case 73:
{
alltax+=tax.calctax(1,current_employee->money);
current_employee->tax=tax.calctax(0,current_employee->money);
if (current_employee->tax==-2)
operate_debug=5;
}
case 105:
{
alltax+=tax.calctax(1,current_employee->money);
current_employee->tax=tax.calctax(0,current_employee->money);
if (current_employee->tax==-2)
operate_debug=5;
}
}
delete current_employee;
linecounter++;
}
}
operate_debuger(operate_debug);
cout <<"所有職工應繳總個人所得稅為:"<<alltax<<"元。"<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -