Taking information out a file and writing to a file

produce two reports, each written to a different file. The first, charges.txt, should contain a well-formatted itemized receipt listing any additional charges for each customer, the number of checked bags, and the number of unaccepted bags (including the reason(s) for not being accepted). The second, summary.txt, should contain overall statistics for the customers processed, including the total weight of the checked bags, the total number of checked bags, the total number of passengers processed, the average weight of the checked bags, and the total additional charges.


Here is the code I have so far:
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
54
55
56
57
58
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
   ifstream in ("data3.txt");
    string fname, lname, fclass, military, membership;
    unsigned int n;
    while(in >> fname >> lname >> fclass >> military >> membership >> n)
    { 
        double weight, l, w, h;
        for(unsigned int i = 0; i < n; ++i)
        {
            in >> weight >> l >> w >> h;

unsigned int cost = 0;
if(i == 0) 

{
    cost += 25;
}
else if(i == 1) 
{
    cost += 35;
}
else 
{
    cost += 100;
}

if(weight > 50.0)
{
    cost += 100;
}
if(weight > 70.0)
    cost += 100; 
}
if(weight > 100.0) 
{
    //bag cannot be checked, cost is not relevant
}

if(max(max(w, l), h) > 62.0)
{
    cost += 100;
}
if(max(max(w, l), h) > 115.0) 
}

  ofstream myfile;
  myfile.open ("summary.txt");
  myfile << "what would I tell it here so it goes into the file?");
  myfile.close();
}

Sample Input
Mark Spitz E RP NO 2 21.5 24.2 18 6 30 26 20.5 7.5
Michael Jordan B RP M4 3 53.7 14.1 9.2 15.0 24.2 5.2 9.3 16.2 109.2 12.1 9.6 23.0
Dorothy Hamill E RP NO 2 55.8 27.1 17.2 18.6 15.0 35.2 21.3 9.2
Sample Output
The above input should produce the following output:
In the file charges.txt


PASSENGER: Mark Spitz
NUMBER OF CHECKED BAGS: 2
TOTAL CHARGES: 60.00
2 checked bags 60.00




PASSENGER: Michael Jordan
NUMBER OF CHECKED BAGS: 2
TOTAL CHARGES: 0.00
NUMBER OF REJECTED BAGS: 1
exceeded weight limit 1



PASSENGER: Dorothy Hamill
NUMBER OF CHECKED BAGS: 2
TOTAL ADDITIONAL CHARGES: 360.00
2 checked bags 60.00
2 oversized bags 200.00
1 overweight bag 100.00


Topic archived. No new replies allowed.