First, I would like to introduce myself. I am an absolute Beginner in C++, and I am taking an Online Intro Course to learn it. I have a background in Computer Animation, as well as IT, so I wanted to learn some Programming. I have been lurking here since I started the Course and I have been amazed by some of what I have read. So when I ran into this proverbial brick wall, I figured this would be the place to help me find an answer.
Ok, so I am at a loss here. I am stuck on building a type of payroll program and I am hoping someone could point me in the right direction. Basically, what I need the program to do is have the User input his/her Employee ID, and then the code would call upon the "employee.txt" file to output the information. Here is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iomanip>
#include <iostream>
#include <C:\...\payroll3\payroll3B\employee.txt>
using namespace std;
ifstream fin.open ("employee.txt");
main() {
int employeeid;
float hoursworked, hourlyrate, grosspay, taxamount, netpay;
float const TAXRATE = 0.30;
cout<<"PLEASE ENTER THE EMPLOYEE NUMBER:";
cin>>employeeid;
grosspay = hoursworked * hourlyrate;
taxamount = grosspay * TAXRATE;
netpay = grosspay - taxamount;
while(fin>>employeeid>>hoursworked>>hourlyrate){
cout<<"YOUR EMPLOYEE ID: "<<setw( 6 )<<setprecision( 4 )<<employeeid<<endl;
cout<<"YOUR HOURS WORKED: "<<setw( 5 )<<setprecision( 4 )<<hoursworked<<endl;
cout<<"YOUR HOURLY RATE: "<<setw( 6 )<<setprecision( 4 )<<hourlyrate<<endl;
cout<<"YOUR GROSS PAY: "<<setw( 8 )<<setprecision( 4 )<<grosspay<<endl;
cout<<"YOUR TAX AMOUNT: "<<setw( 7 )<<setprecision( 4 )<<taxamount<<endl;
cout<<"YOUR NET PAY: "<<setw( 10 )<<setprecision( 4 )<<netpay<<endl;
}//WHILE
fin.close (""employee.txt");
system ( "pause" );
return 0;
} //MAIN
|
And here are the errors I am getting:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
C:\...\payroll3\payroll3B\employee.txt|1|error: expected unqualified-id before numeric constant|
C:\...\payroll3\payroll3B\employee.txt|1|error: expected `,' or `;' before numeric constant|
C:\...\payroll3\payroll3B\main.cpp|7|error: `ifstream' does not name a type|
C:\...\payroll3\payroll3B\main.cpp|9|warning: ISO C++ forbids declaration of `main' with no type|
C:\...\payroll3\payroll3B\main.cpp||In function `int main()':|
C:\...\payroll3\payroll3B\main.cpp|13|error: `cout' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|13|error: (Each undeclared identifier is reported only once for each function it appears in.)|
C:\...\payroll3\payroll3B\main.cpp|14|error: `cin' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|18|error: `fin' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|19|error: `setw' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|19|error: `setprecision' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|19|error: `endl' undeclared (first use this function)|
C:\...\payroll3\payroll3B\main.cpp|26|error: expected `)' before "employee"|
C:\...\payroll3\payroll3B\main.cpp|26|error: missing terminating " character|
||=== Build finished: 12 errors, 1 warnings ===|
|
And here is what my "employee.txt" file, which is supposed to provide the Employee Number, Hours Worked and Pay Rate in order, looks like:
1 2 3 4 5
|
1234 38 17.50
5678 40 22.50
9098 37 15
7654 39 18
3210 40 20
|
What am I missing here? I was up half the night trying to figure this out and I seem to be stuck at this point. Thanks in advance, and any help would be greatly appreciated!
EDIT: Added code tags per suggestion.