请指出具体的地方以及需要进行哪些新的具体编辑。我不断收到相同的错误,我不知道出了什么问题。我已经检查了 100 万次括号,并且很确定我做对了:
- cpp:36: 错误: '{' 标记之前不允许函数定义
- cpp:44: 错误: '{' 标记之前不允许函数定义
- cpp:58: 错误:“double”之前的预期初始化程序</li>
- cpp:63: 错误: '{' 标记之前不允许函数定义
- cpp:69: 错误: '{' 标记之前不允许函数定义
代码:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string item = "";
ifstream fin;
double tgross = 0;
double tnet = 0;
double hourly;
double hours;
double taxrate;
double net;
string fileName = "payroll.txt";
fin.open("payroll.txt");
if(!fin.is_open())
{
void instructions()
{
cout << "This payroll program calculates an individual employee pay and";
cout << "\ncompany totals using data from a data file payroll.txt.\n";
cout << "\n\nA payroll report showing payroll information ";
cout << " is displayed.\n\n";
}
void reportTitle()
{
cout << setprecision(2) << fixed << showpoint << left
<< setw(20) << "Employee" << setw(10) << "Hourly" << setw(10) << "Hours"
<< setw(10) << "Tax" << setw(10) << "Gross" << setw(10) << "Net" << endl;
cout << setw(20) << "Name" << setw(10) << "Rate" << setw(10) << "Worked"
<< setw(10) << "Rate" << setw(10) << "Amount" << setw(10) << "Amount" << endl;
}
}
while(!fin.eof())
{
getline(fin,item,'#');
fin >> hourly >> hours >> taxrate;
double calculateGross(double hours, double hourly)
double calculateNet(double grosspay, double netpercent)
{
return grosspay - grosspay*netpercent/100.0;
}
void displayEmployeeInfo(const string &, double, double, double, double, double)
{
tgross += grosspay;
tnet += net;
}
}
void totalAmounts (double tgross, double tnet)
{
cout << "Totals" << setprecision(2) << fixed << showpoint << right
<< setw(50) << tgross << setw(10) << tnet << endl;
}
fin.close();
}