I got the first function tagReader to work, but how do I get the program to read the other functions such as getEmployee, paycheck, repeater, valid, and header.
Here is all I get for the output:
Results from tags1.txt :
Cylinder: bsharkdata 1782 12.00 82.90
Cylinder: ftmyersfeb 7150 11.00 32.89
Cylinder: sandiego99 8800 15.20 52.76
Cylinder: turtles666 2180 11.00 14.09
Cylinder: turtles765 4223 11.90 17.10
Cylinder: FredsFish 4145 11.60 42.22
Cylinder: GreatBaReef 8673 10.00 11.40
Cylinder: VaBch77June 1111 13.50 44.00
File tags1.txt had 8 data items.
Results from tags2.txt :
Cylinder: turtles686 2110 14.88 65.19
Cylinder: turtles995 1123 61.60 77.17
Cylinder: UKFishData 4145 99.04 22.98
Cylinder: Gr8BaReef2 8673 19.71 76.12
Cylinder: VaBch78876 1111 69.11 51.10
Cylinder: shark9987 1782 83.40 89.11
Cylinder: florida331 3130 14.01 52.89
Cylinder: florida876 6600 15.20 52.76
Cylinder: flKeys331 4410 64.66 56.22
Cylinder: flKeys877 6630 16.27 52.77
File tags2.txt had 10 data items.
Press any key to continue . . .
How do I get the program to continue to call all functions is in my program?
#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;
string cylinder, serial;
double num1, num2;
double counter;
//----------------------------------------
// 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;
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
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++;
}
}
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
void getEmployee (string& who, double& rate, int &hours)
{
string lastName;
cout << "Input the employee's last name: ";
cin >> lastName;
cout << "Input the number of hours worked: ";
cin >> hours;
cout << "Input the payrate: ";
cin >> rate;
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
double paycheck (int hours, double rate)
{
double paycheck;
double overtime;
double overtime_check;
cout << "The employee has worked " << 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;
}
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
void repeater ( string word, int num)
{
cout << "Enter a word: ";
cin >> word;
cout << "\nHow many times would you like this word processed? ";
cin >> num;
for(int i=0;i<num;i++)
{
cout << "word";
}
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
bool valid (int val)
{
if(75 <= val <= 100)
{
cout << "True" << endl;
return true;
}
else
{
cout << "False" << endl;
return false;
}
}
//**********************************************************************
//Function Name: GetLength
// Prompts the user to input the lenth of a rectangular room
// Returns the int value input by the user
//**********************************************************************
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;
}
//-----------------------------------------------------}