Output not printing correctly
The output file is missing the beginning of the string gameName following the first from the input file and not sure how to fix
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
while( getline(fin >> ws, gameName))
{
fin >> costTicket;
fin >> numPrize;
totalAmount = dollarAmount + costTicket;
remainTicketProfit = 0;
remainTicket = 0;
for( int i = 0; i < numPrize; i ++)
{
fin >> prizeValue;
fin >> totalTicket;
fin >> notClaimed;
remainTicket = remainTicket + notClaimed;
if ( prizeValue > dollarAmount)
{
remainTicketProfit = remainTicketProfit + notClaimed;
}
}
if(remainTicketProfit == 0)
{
myfile << left << setw(25) << gameName << setw(2) << "$" << setw(7) << costTicket << left << setw(17) << "Not possible" << endl;
}
else
{
odds = remainTicket / remainTicketProfit;
myfile << left << setw(25) << gameName << setw(2) << "$" << setw(7) << costTicket << "1 in " << fixed << setprecision(2) << odds << endl;
}
fin >> blankLine;
|
Topic archived. No new replies allowed.