I have been given and assignment to read a file of data listed below:
Turn on the Bright Lights
Interpol
9.49
House of Jealous Lovers
The Rapture
1.29
Fever to Tell
Yeah Yeah Yeahs
6.99
Desperate Youth, Blood Thirsty Babes
TV on the Radio
8.91
The Fragile
Nine Inch Nails
12.49
Input this data into C++ and then display in a matrix and output total price of the cd's and how many cd's were sold. So far I can only get the first line to display properly and cannot figure out what I need to change to get the rest to display. Here is what I have written thus far. I have not started on the output code and feel as though I will not have an issue with that.
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
ifstream inputFile, processLine;
ofstream outputFile;
string title, band;
double price, total = 0;
inputFile.open("orders.txt");
while (!inputFile.eof())
{
getline(inputFile, title);
getline(inputFile, band);
inputFile >> price;
total += price;
cout << "Welcome to Megan McCracken's Online Music Store" << endl;
cout << "You have submitted the following order:" << endl;
cout << "***************************************************************************" << endl;
cout << "Title" << setw(46) << "Artist" << setw(24) << "Cost" << endl;
cout << title << setw(28) << band << setw(22) << fixed << setprecision(2) << price << endl;
cout << title << setw(30) << band<< setw(19) << fixed << setprecision(2) << price << endl;
cout << title << setw(20) << band << setw(20) << fixed << setprecision(2) << price << endl;
cout << title << setw(20) << band << setw(20) << fixed << setprecision(2) << price << endl;
cout << title << setw(20) << band << setw(20) << fixed << setprecision(2) << price << endl;
cout << "--------------------------------------------------------------------------" << endl;
cout << "Total Due:" << setw(75) << fixed << setprecision(2) << total << endl;
cout << "==========================================================================" << endl;
}
/* getline(inputFile, title);
cout << left << title;
getline(inputFile, band);
cout << setw(23) << band;
inputFile >> price;
cout << setw(10) << fixed << setprecision(2) << price << endl; */
system("pause");
return 0;
}