Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream store;
- int LowRange = 0;
- int Midrange = 0;
- int HighRange = 0;
- int price = 0;
- char Product[] = {0};
- store.open("C:\\Users\\BOGOMIL\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication6\\store.txt" );
- if (store.fail()) {
- cout << "Failed to open file"<< endl;
- return -1;
- }
- while (!store.eof()) {
- store.get(Product, 10, '$');
- ofstream Prices("Prices.txt");
- if (price <= 10 && price > 0) {
- LowRange++;
- }
- else if (price <= 20 && price > 10) {
- Midrange++;
- }
- else if (price > 20) {
- HighRange++;
- }
- Prices << "Products in the 0-10 range" << " " << LowRange << endl;
- Prices << "Products in the 10-20 range" << " " << Midrange << endl;
- Prices << "Products in the 20+ range" << " " << HighRange << endl ;
- }
- ifstream Prices;
- Prices.open("Prices.txt");
- if (Prices.fail()) {
- cout << "Failed to open file";
- return -1;
- while (!Prices.eof()) {
- cout << Prices.get();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement