I have to read an input file calls_history.txt that is like this
Mo  13:30   16
Mo  8:15    35
Tu  7:50    20
We  17:45   30
Th  8:00    45
Su  23:50   30
And then calculate the cost of each calls. So far, this is what I got.
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;
int main()
{
    ifstream inFile;
    string filename, day, Mo, Tu, We, Th, Fr, Sa, Su;
    int duration;
    string time_start;
    int hour_start, minute_start;
    double TotalCost, cost_1, cost_2;
    cout << "Enter filename: ";
    cin >> filename;
    cout << "Day" << "\tTime" << "\tDuration" << "\tCost" << endl;
    cout << "----------------------------------------------" << endl;
    inFile.open (filename.c_str());
    string line;
    if (inFile)
    {
//read records from file
    while (getline (inFile, line))
    {
        stringstream iss(line);
     //split into 3 fields
        while(iss)
    {
        iss >> day;
        iss >> hour_start;
        iss >> minute_start;
        iss >> duration;
    }
        if (day == "Mo" || day == "Tu" || day == "We" || day == "Th" || day == "Fr")
        {
                if (hour_start >= 8 && hour_start <= 18)
                {
                    TotalCost = duration*0.40;
                }
                if ((hour_start = 7, minute_start < 60) && (minute_start+duration >= 60))
                {
                    cost_1 = (60-minute_start)*0.25;
                    cost_2 = ((duration-(60-minute_start))*0.40);
                    TotalCost = cost_1+cost_2;
                }
                if (hour_start < 8 && hour_start >= 18)
                {
                    TotalCost = duration*0.25;
                }
        }
        if (day == "Sa" || day == "Su")
        {
                if ((hour_start =23 && minute_start <60)&& (minute_start+duration >=60))
                {
                    cost_1 = (60-minute_start)*0.15;
                    cost_2 = ((duration-(60-minute_start))*0.25);
                    TotalCost = cost_1+cost_2;
                }
                else
                {
                    TotalCost = duration*0.15;
                }
        }
     cout << day << "\t" << hour_start <<":" << minute_start << "\t" << duration << "\t\t$";
     cout << setprecision(2) << fixed << TotalCost << endl;
        inFile.close();
    }
    }
    return 0;
}I tested it out and only got this result
Enter filename: calls_history.txt
Day     Time    Duration        Cost
----------------------------------------------
Mo      7:30    16              $6.40
Process returned 0 (0x0)   execution time : 3.622 s
Press any key to continue.Any suggestion so that I can show all the other lines and datas? I have to make it look like this
Day Time Duration Cost
Mo 13:30 16         $6.40
Mo 8:15 35         $14.00
Tu 7:50 20         $6.50
We 17:45 30         $9.75
Th 8:00 45         $18.00
Su 23:50 30         $6.50
Total                         $61.15 
    