I have seemed to get the first function tagReader to work, but can't get the others to work. The other functions are bolded.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
// function prototypes
void tagReader ( ifstream& inFile, int&count);
void getEmployee ( string& who, double& rate, int &hours );
double paycheck (int hours, double rate);
void repeater ( string word, int num);
bool valid (int val);
void header ();
//=========================================================
int main()
{
int count = 0;
ifstream inFile;
//----------------------------------------
// Call function tagReader with tags1.txt
inFile.open("tags1.txt");
if (!inFile)
{
cout << "\n\nError! - Invalid file name! (1)\n\n";
system ("pause");
return 1;
}
cout <<"Results from tags1.txt :\n";
tagReader ( inFile, count);
cout << "File tags1.txt had " << count << " data items. \n\n";
inFile.close ();
//----------------------------------------
// Call function tagReader with tags2.txt
inFile.clear ();
inFile.open("tags2.txt");
if (!inFile)
{
cout << "\n\nERROR! Invalid file name! (2)\n\n";
system ("pause");
return 1;
}
cout <<"Results from tags2.txt :\n";
tagReader ( inFile, count);
cout << "File tags2.txt had " << count << " data items. \n\n";
inFile.close ();
system("pause");
return 0;
}
//**********************************************************************
//**********************************************************************
void tagReader (ifstream& inFile, int&count)
{
string cylinder, serial;
double num1, num2;
inFile >> cylinder;
while (!inFile.eof())
{
inFile>> serial;
inFile >> num1;
inFile >> num2;
cout << fixed << showpoint << setprecision(2);
cout <<"\nCylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl;
count = 0;
count++;
while (!inFile.eof())
{ inFile >> cylinder ;
inFile >> serial;
inFile >> num1;
inFile >> num2;
cout << "\nCylinder: " << cylinder << " " << serial << " " << num1 << " " << num2 << endl << endl;
count++;
}
}
}
//**********************************************************************
//**********************************************************************
void getEmployee (string& who, double& rate, int &hours)
{
string lastName;
cout << "\nInput the employee's last name: ";
cin >> lastName;
cout << "\nInput the number of hours worked: ";
cin >> hours;
cout << "\nInput the payrate: $";
cin >> rate;
cout << "\nHello " << lastName << "! You have worked " << hours << " hour(s) at a payrate of $" << rate << " an hour.\n" << endl;
}
//**********************************************************************
//**********************************************************************
double paycheck (int hours, double rate)
{
double paycheck;
double overtime;
double overtime_check;
cout << "The employee has worked " << hours << " hours." << endl;
if(hours <=40)
{
paycheck = hours * rate;
cout << "\nThe employee has earned $" << paycheck << " dollar(s)." << endl;
}
else if(hours > 40)
{
overtime = (hours - 40) * rate * 1.5;
overtime_check = paycheck + overtime;
cout << "\nThe employee has earned $" << paycheck << " dollar(s) of overtime pay." << endl;
cout << "\nTherefore, the employee has earned $" << paycheck << " dollar(s)." << endl;
}
}
//**********************************************************************
//**********************************************************************
void repeater ( string word, int num)
{
cout << "\nEnter a word: ";
cin >> word;
cout << "\nHow many times would you like this word processed? ";
cin >> num;
cout << "" << endl;
for(int i=0;i<num;i++)
{
cout << word << endl;
}
cout << "\nThe word " << word << " appeared " << num << " times." << endl << endl;
}
//**********************************************************************
//**********************************************************************
bool valid (int val)
{
cout << "Enter a value between 75 and 100: ";
cin >> val;
if(75.0 <= val && 100 >= val)
{
cout << "\nTrue" << endl << endl;
}
else
{
cout << "\nFalse" << endl << endl;
}
}
//**********************************************************************
//**********************************************************************
void header ()
{
cout << endl;
cout << "Driver Name: Peter Langlands - first 3; Tyler Bazan - second 3" << endl;
cout << "Navigator Name: Tyler Bazan - first 3; Peter Langlands - second 3" << endl;
cout << "Date: March 3, 2011" << endl;
cout << "Lab CRN 26682\n" << endl;
}
//-----------------------------------------------------}