#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int numberofemployees;
int employeeid, hoursworked;
float hourlyrate, grosspay, taxamount, netpay;
const float TAXRATE=0.10;
std::ifstream fin("employee.txt");
while (!fin.eof() )
{
fin >> employeeid >>hoursworked >> hourlyrate;
std::cout<<"THE EMPLOYEE ID IS: "<<employeeid<<endl;
std::cout<<"THE HOURS WORKED ARE: "<<hoursworked<<endl;
std::cout<<"THE HOURLY RATE IS: "<<hourlyrate<<endl;
grosspay=hoursworked*hourlyrate;
taxamount=grosspay*TAXRATE;
netpay=grosspay-taxamount;
std::cout<<"THE GROSSPAY IS: "<<grosspay<<endl;
std::cout<<"THE TAX MOUNT IS: "<<taxamount<<endl;
std::cout<<"THE NETPAY IS: "<<netpay<<endl;
}
fin.close ();
getchar ();
return 0;
}//MAIN
std::string line;
while (getline(fin, line)) {
// do something with 'line'. You could for example use a stringstream to extract the values from it
}
C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.
TRUSTED BY