I do not know how to write a function for this. I have written just the base line of the code, but I do not know how to finish it. Here is the description.
A void Function tagReader inputs the data collected by the cylinders; it has two parameters: the input file and an int count. The function inputs names, serial numbers, and location coordinates from the input file. The input file will have a descriptive name, an integer serial number and two double values representing map coordinates separated by blanks on each line. For each cylinder, echo print to the screen, the name, serial number and both coordinate values along with the value of the smaller coordinate value. Use an EOF controlled while loop. A count of the number of entries in the file will be returned to the caller via the reference parameter count.
tags1.txt
bsharkdata 1782 12.00 82.90
ftmyersfeb 7150 11.00 32.89
sandiego99 8800 15.20 52.76
turtles666 2180 11.00 14.09
turtles765 4223 11.90 17.10
FredsFish 4145 11.60 42.22
GreatBaReef 8673 10.00 11.40
VaBch77June 1111 13.50 44.00
tags2.txt
turtles686 2110 14.88 65.19
turtles995 1123 61.60 77.17
UKFishData 4145 99.04 22.98
Gr8BaReef2 8673 19.71 76.12
VaBch78876 1111 69.11 51.10
shark9987 1782 83.40 89.11
florida331 3130 14.01 52.89
florida876 6600 15.20 52.76
flKeys331 4410 64.66 56.22
flKeys877 6630 16.27 52.77
#include <iostream>
#include <fstream>
#include <iomanip>
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;
int first, last;
//----------------------------------------
// 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)
{
}