I'm writing this program where I write data to s file and the read it from it. Here is my code:
Code:
#include<iostream>
#include<string>
#include<iomanip>
#include<fstream>  //for using files

using namespace std;

int main(){
    int hours;
    double bill = 0; //total charge
    char package;
    string name, line;

    ofstream output_file;   //to write bill
    ifstream input_file;    //to display bill

    cout << "welcome to your bill.\nPlease enter your first name.\n";
    cout << ">>";
    cin >> name;

    cout << "select the internet package you have:\n";
    cout << "Pacakage A\nPackage B\nPackage C\n";
    cin >> package;
    package = toupper(package);

    cout << "enter the amount of hours you used the service: ";
    cin >> hours;

    switch(package){
        case 'A':
            bill = hours <= 10? 9.95 : (9.5 + (2*(hours - 10))); //calculate price
            break;
        case 'B':
            bill = hours <= 20? 14.95 : (14.95 + (1 * (hours - 20)));
            break;
        case 'C':
            bill = 19.95;
            break;
        default :
                    cout<< "you entered an invalid choice";

    }
    


    //write data to file
    
    output_file.open("bill.txt");
    output_file << name << "\n";
    output_file << "you have package " << package << "\n";
    output_file << "you have used " << hours << " hours this month\n";
    output_file <<"your bill is " << bill << " dollars.\n";
    output_file.close();

    input_file.open("bill.txt");
    getline(input_file, line, '.');
    cout << line << endl;

    input_file.close();

return 0;

}
the problem I have is that it doesn't read the word "dollars" even though is before the '.'
sample output
Code:
welcome to your bill.
Please enter your first name.
>>peter
select the internet package you have:
Pacakage A
Package B
Package C
b
enter the amount of hours you used the service: 5
peter
you have package B
you have used 5 hours this month
your bill is 14
Also how can I display the correct amount. When I look at the text file everything seems to be written to it.