Created
April 20, 2017 05:23
-
-
Save anonymous/ddf4f71edcd133f4588c41eb711840bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
Book b; | |
vector<Book> books; | |
string tempTitle, tempAuthor, tempisbn, tempPrice, tempCost, tempqtyOnHand, tempqtySold; | |
ofstream out("new_list.txt"); | |
ifstream inClientFile{ "Book_List.txt" }; | |
if (!inClientFile) { | |
cerr << "File could not be opened" << endl; | |
exit(EXIT_FAILURE); | |
} | |
while (inClientFile.peek() != EOF) { | |
//CreateBook to store data, call it b | |
inClientFile >> quoted(b.title) >> quoted(b.author) >> quoted(tempPrice) >> quoted(tempqtyOnHand) >> quoted(tempqtySold) >> quoted(tempisbn) >> tempCost; | |
inClientFile.ignore(); | |
b.price = stod(tempPrice); | |
b.qtyOnHand = stoi(tempqtyOnHand); | |
b.qtySold = stoi(tempqtySold); | |
b.cost = stod(tempCost); | |
out << b.title << ", " << b.author << ", " << b.price << ", " << b.qtyOnHand << ", " << b.qtySold << ", " << b.isbn << ", " << b.cost << ", " << b.calcRevenue(b.price, b.qtySold) << ", " << b.calcProfit(b.price, b.cost, b.qtySold) << endl; | |
books.push_back(b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment