Hello, I am trying to read in from a file named"parking.txt", and I want to read certain values from this file and output them to the screen. How can this be done? Can this be done?
The values in parking.txt is:
total 5
One 400
Five 300
Ten 200
Twenty 50
Quarter 500
In my code I would like to replace "line" with the appropriate value from the file.
#include <iostream>
#include <fstream>
#include <iomanip>
usingnamespace std;
int main()
{
ifstream inputFile ("parking_account.txt");
string line;
getline(inputFile, line);
cout <<"\n\t-------------------------------------------------------";
cout <<"\n\t=======================================================";
cout <<"\n\t Parking Machine Accounts ";
cout <<"\n\t=======================================================";
cout <<"\n\tSr. No. : Bill Name : Bill Count : Cost(in$) ";
cout <<"\n\t-------------------------------------------------------";
cout <<"\n\t 1 : One Dollar : " << line << " : ";
cout <<"\n\t 2 : Five Dollar : " << line << " : ";
cout <<"\n\t 3 : Ten Dollar : " << line << " : ";
cout <<"\n\t 4 : Twenty Dollar : " << line << " : ";
cout <<"\n\t 5 : Quarter : " << line << " : ";
cout<<"\n\tTotal bill types found : " <<line <<endl;
}
I have tried a while loop that searches line by line, but it outputs 5 of the same menus with line updated for that text value. Here is the while loop.