Need help aligning this table.
I know what the problem is, I just don't know how to fix it.
Any help would be very appreciated, Thank you.
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
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
string name = "";
int quantity = 0;
double price = 0.0;
ifstream inFile;
inFile.open("Advanced25.txt", ios::in);
if (inFile.is_open())
{
getline(inFile, name, '#');
inFile >> quantity;
inFile.ignore(1);
inFile >> price;
inFile.ignore(1);
cout << "Name" << '\t' << "Quantity" << '\t' << "Price" << endl;
while (!inFile.eof())
{
cout << name << '\t' << quantity << '\t' << fixed <<
setprecision(2) << price << endl;
inFile >> quantity;
inFile.ignore(1);
inFile >> price;
inFile.ignore(1);
}
inFile.close();
}
else
cout << "The file could not be opened" << endl;
system("pause");
return 0;
} //End of main function.
//These are the results I'm getting.
//Name Quantity Price
//Watch 25 40.00
//Ring 55 99.99
//Bracelet 60 20.00
//Earrings 65 17.85
//Pins 20 53.50
//Press any key to continue . . .
|
Topic archived. No new replies allowed.