c++ - 'g++' 不是内部或外部命令、可运行程序或批处理文件。视觉工作室代码
问题描述
我正在编写一个从输入文件“payroll.txt”读取数据的程序。我已经使用记事本创建了文件。但是我遇到了一个问题当我运行程序时,我收到以下错误:'g++' 不被识别为内部或外部命令、可运行程序或批处理文件。 我已经安装了 minGW- 并在系统环境变量设置中配置了 PATH。在此处输入图像描述 这是我的代码
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void instructions();
void reportTitle();
void displayEmployeeInfo(string employeeName, double hourlyRate,
double hoursWorked, double taxRate, double grossAmount,
double netAmount);
void totalAmounts(double totalGrossAmount, double totalNetAmount);
int main()
{
ifstream infile;
string employeeName;
double hourlyRate, hoursWorked, taxRate, grossAmount, netAmount,
totalGrossAmount = 0.0, totalNetAmount = 0.0;
infile.open("payroll.txt");
if (!infile) {
cout << "Input failed." << endl;
return 1;
}
instructions();
reportTitle();
getline(infile, employeeName, '#');
infile >> hourlyRate >> hoursWorked >> taxRate;
infile.ignore(100, '\n');
while (!infile.eof()) {
grossAmount = hoursWorked * hourlyRate;
if (hoursWorked > 40)
grossAmount += (hoursWorked * hourlyRate * .5);
netAmount = grossAmount - (grossAmount * taxRate / 100);
totalGrossAmount += grossAmount;
totalNetAmount += netAmount;
displayEmployeeInfo(employeeName, hourlyRate, hoursWorked, taxRate,
grossAmount, netAmount);
getline(infile, employeeName, '#');
infile >> hourlyRate >> hoursWorked >> taxRate;
infile.ignore(100, '\n');
}
totalAmounts(totalGrossAmount, totalNetAmount);
return 0;
}
void instructions()
{
cout << "This payroll program calculates an individual "
<< "employee pay and\ncompany totals "
<< "using data from a data file payroll.txt. \n"
<< "\n\nA payroll report showing payroll information "
<< "is displayed.\n\n";
}
void reportTitle()
{
cout << setprecision(2) << fixed << showpoint << left;
cout << setw(24) << "Employee" << setw(11) << "Hourly"
<< setw(11) << "Hours" << setw(9) << "Tax"
<< setw(11) << "Gross" << setw(10) << "Net" << endl;
cout << setw(25) << "Name" << setw(9) << "Rate" << setw(12)
<< "Worked" << setw(8) << "Rate" << setw(10) << "Amount"
<< setw(10) << "Amount" << endl
<< endl;
}
void displayEmployeeInfo(string employeeName, double hourlyRate,
double hoursWorked, double taxRate, double grossAmount,
double netAmount)
{
cout << left << setw(25) << employeeName << right << setw(5)
<< hourlyRate << setw(10) << hoursWorked << setw(10) << taxRate
<< setw(10) << grossAmount << setw(10) << netAmount << endl;
}
void totalAmounts(double totalGrossAmount, double totalNetAmount)
{
cout << left << setw(26) << "\nTotals" << right << setw(35)
<< totalGrossAmount << setw(10) << totalNetAmount << endl;
}
解决方案
推荐阅读
- php - 搜索最小值时从关联数组返回 array_column
- c# - 如何从 Frame 访问 CommandBar 控件
- ios - AppCenter 不会更改 Flutter 中的共享方案配置
- awk - 使用 sed 或 awk 在每 n 行之后引入顺序字符串
- node.js - 为什么mongodb会自动将字符串转换为long?
- c# - 为什么代码不将某些资产视为预制件?
- c# - 实体框架不加载具有多对多关系的数据
- swift - SwiftUI 仅在查看 ContentView 时隐藏导航栏
- python - 如何在 python 3 中写入文本文件?
- python - 换行符不适用于我的程序?