#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream fin;
string firstName;
string lastName;
int horseNumber;
int betAmount;
fin.open("jockey.txt");
if (!fin.good())
{
cerr << "File not found\n";
return 1;
}
for (int i=0; i<10; i++)
{
fin >> firstName >> lastName >> horseNumber >> betAmount;
cout << "Name is : " << firstName << " " <<lastName << " " << horseNumber<< " " << betAmount <<endl;
}
fin.close();
system("pause");
return 0;
}
"jockey.txt"
Peter Pan 1 33
Robin Hood 1 41
Jack Sparrow 2 90
Michael Jackson 3 47
Snoop Dogg 4 29
Peter Pan 2 12
Robin Hood 3 71
Jack Sparrow 3 49
Michael Jackson 3 47
Snoop Dogg 4 29
...
Robin Hood 3 5
hi all... got a assignment that needs some help... i'm trying to read from a text file called "jockey.txt" and calculate the bet amount total received from 4 different customers for 5 different jockeys... the 1st field is first name, followed by last name of the jockey... 3rd field is customer number and 4th is the amount...
their name may appear more than once in the txt file... the expected output would be something like this:
======== Cust 1_Cust 2_Cust 3_Cust 4_Total========
Peter Pan_____33_____0_____0_____0___33
Robin Hood___ 41_____0_____5_____0___46 (ignore all the underscores... they're suppose to be spaces...)
Most popular jockey: xxxx amount received xxxx
total amount received in all: xxxx
i'm really out of wits on how to do this... i can only store the input into variables at the moment only (the one i posted)... any pointers or advice would be greatly appreciated...! thanks in advance... :confused: