Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. using namespace std;
  5. int main() {
  6. ifstream store;
  7. int LowRange = 0;
  8. int Midrange = 0;
  9. int HighRange = 0;
  10. int price = 0;
  11. char Product[] = {0};
  12. store.open("C:\\Users\\BOGOMIL\\Documents\\Visual Studio 2015\\Projects\\ConsoleApplication6\\store.txt" );
  13. if (store.fail()) {
  14. cout << "Failed to open file"<< endl;
  15. return -1;
  16. }
  17. while (!store.eof()) {
  18. store.get(Product, 10, '$');
  19. ofstream Prices("Prices.txt");
  20.  
  21. if (price <= 10 && price > 0) {
  22.  
  23. LowRange++;
  24. }
  25.  
  26. else if (price <= 20 && price > 10) {
  27. Midrange++;
  28. }
  29.  
  30. else if (price > 20) {
  31. HighRange++;
  32. }
  33. Prices << "Products in the 0-10 range" << " " << LowRange << endl;
  34. Prices << "Products in the 10-20 range" << " " << Midrange << endl;
  35. Prices << "Products in the 20+ range" << " " << HighRange << endl ;
  36. }
  37. ifstream Prices;
  38. Prices.open("Prices.txt");
  39. if (Prices.fail()) {
  40. cout << "Failed to open file";
  41. return -1;
  42. while (!Prices.eof()) {
  43. cout << Prices.get();
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement