#include <iostream>

#include <string>

#include <fstream>

#include <iomanip>

 

using namespace std;

float saved (int, double);

 

int main()

{

       string name;

       int items;

       double cost;

       float total_saved;

       int itemtotal = 0;

       double costtotal = 0;

       int count = 0;

       double average;

 

       ifstream fin;

 

       fin.open("Bargain.txt");

 

       if (fin.fail())

       {

              cerr << "File not found";

              exit(1);

       }

 

       cout << setw(15) << "contestants " << setw(15) << "items"

              << setw(15)<< "Amount" << setw(15)<< "totalsaved" << endl;

       cout << setprecision(2) << fixed;

       while (!fin.eof())

       {

              fin >> name >> items >> cost;

 

              total_saved = saved(items, cost);

              cout << setw(15) << name << setw(15) << items

                     << setw(15)<< cost << setw(15)<< total_saved<< endl;

              itemtotal = itemtotal + items;

              costtotal = costtotal + total_saved;

              count ++;

       }

 

       average = costtotal / count;

       cout << "The average amount saved is: " << average << endl;

       cout << "The total number of items is "  << itemtotal << endl;

 

       return 0;

}

 

float saved (int it, double c )

{

       return (it * c);

}