#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
usingnamespace std;
int main() {
string line;
double price = 0;
double total = 0;
int i = 1, j = 0;
cout << "Welcome to Steven Kidwell's Online Music Store. You have" << endl;
cout << "submitted the following order:" << endl;
cout << "***************************************************************************" << endl;
ifstream inputFile;
inputFile.open("orders.txt");
while (getline(inputFile, line)){
cout << line << endl;
if (i < 3) {
i++;
}
else {
i = 1;
price = atof(line.c_str());
total += price;
j++;
}
}
ofstream outputFile;
outputFile.open("summary.txt");
outputFile << "Downloads: " << j << endl;
outputFile << "Total Due: " << total << endl;
system("pause");
return 0;
}
this is my txt file i read from
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
You are not really having trouble displaying them, since you haven't even read them in correctly yet. I am certain you are suppose to use an array here to read them in.
Your text file you are reading in from is as follows:
Record
Artists
Price
So you need three variables to store these information in, most likely in the form or arrays or vectors. Displaying them, in your case, is perhaps more easy than reading values in.
Thomas1965, that definitely works and makes sense but I will still need my original while if and else statements because not only do i need the console to display my columns I need to have my output file still display downloads; and total due;....