Guest User

Untitled

a guest
Dec 15th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.35 KB | None | 0 0
  1. #include "product.h"
  2. #include <sstream>
  3.  
  4. int main()
  5. {
  6. Product Inventory[100];
  7. int itemline = 0;
  8. double subTotal = 0.0;
  9. fstream filestr ("inventory.txt", fstream::in | fstream::out);
  10. int PLU;
  11. string name;
  12. int type;
  13. double priceper;
  14. double inventory;
  15.  
  16. if (filestr.is_open())
  17. {
  18.     while(!(filestr.eof()) && (itemline < 100))
  19.     {
  20.            
  21.             filestr >> PLU >> name >> type >> priceper >> inventory;
  22.            
  23.             Inventory[itemline].setPLU(PLU);
  24.             Inventory[itemline].setName(name);
  25.             Inventory[itemline].setType(type);
  26.             Inventory[itemline].setPricePer(priceper);
  27.             Inventory[itemline].setInventory(inventory);
  28.             Inventory[itemline].setexists(true);
  29.             itemline++;
  30.             cout << Inventory[itemline];
  31.             cout << "older" << Inventory[itemline-1];
  32.            
  33.            
  34.            
  35.     }
  36.  
  37.     filestr.close();
  38. }
  39. else cout << "Unable to open file";
  40.  
  41.  
  42. cout << "closed";
  43. for(int i =0 ; i!= itemline; i++)
  44. {
  45. cout << Inventory[i];
  46. }
  47.  
  48. int printcount = 0;
  49. ofstream outfile ("output.txt");
  50. if(outfile.is_open())
  51. {    
  52.     while(printcount != itemline && Inventory[printcount].exists())
  53.     {
  54.             outfile << Inventory[printcount];
  55.             //outfile.flush();
  56.             printcount++;
  57.     }
  58.     outfile.close();
  59. }
  60.  
  61. return 0;
  62.  
  63. }
  64.  
  65.  
  66. output
  67. 4101 BRAEBURN_REG 1 0.99 101.5
  68. older4101 BRAEBURN_REG 1 0.99 101.5
  69. 4021 DELICIOUS_GDN_REG 1 0.89 94.2
  70. older4021 DELICIOUS_GDN_REG 1 0.89 94.2
  71. 4020 DELICIOUS_GLDN_LG 1 1.09 84.2
  72. older4020 DELICIOUS_GLDN_LG 1 1.09 84.2
  73. 4015 DELICIOUS_RED_REG 1 1.19 75.3
  74. older4015 DELICIOUS_RED_REG 1 1.19 75.3
  75. 4016 DELICIOUS_RED_LG 1 1.29 45.6
  76. older4016 DELICIOUS_RED_LG 1 1.29 45.6
  77. 4167 DELICIOUS_RED_SM 1 0.89 35.4
  78. older4167 DELICIOUS_RED_SM 1 0.89 35.4
  79. 4124 EMPIRE 1 1.14 145.2
  80. older4124 EMPIRE 1 1.14 145.2
  81. 4129 FUJI_REG 1 1.05 154.5
  82. older4129 FUJI_REG 1 1.05 154.5
  83. 4131 FUJI_X-LGE 1 1.25 164.1
  84. older4131 FUJI_X-LGE 1 1.25 164.1
  85. 4135 GALA_LGE 1 1.35 187.7
  86. older4135 GALA_LGE 1 1.35 187.7
  87. 4133 GALA_REG 1 1.45 145.2
  88. older4133 GALA_REG 1 1.45 145.2
  89. 4139 GRANNY_SMITH_REG 1 1.39 198.2
  90. older4139 GRANNY_SMITH_REG 1 1.39 198.2
  91. 4017 GRANNY_SMITH_LGE 1 1.49 176.5
  92. older4017 GRANNY_SMITH_LGE 1 1.49 176.5
  93. 3115 PEACHES 1 2.09 145.5
  94. older3115 PEACHES 1 2.09 145.5
  95. 4011 BANANAS 1 0.49 123.2
  96. older4011 BANANAS 1 0.49 123.2
  97. 4383 MINNEOLAS 1 0.79 187.3
  98. older4383 MINNEOLAS 1 0.79 187.3
  99. 3144 TANGERINES 1 1.19 135.5
  100. older3144 TANGERINES 1 1.19 135.5
  101. 4028 STRAWBERRIES_PINT 0 0.99 104
  102. older4028 STRAWBERRIES_PINT 0 0.99 104
  103. 4252 STRAWBERRIES_HALF_CASE 0 3.99 53
  104. older4252 STRAWBERRIES_HALF_CASE 0 3.99 53
  105. 4249 STRAWBERRIES_FULL_CASE 0 7.49 67
  106. older4249 STRAWBERRIES_FULL_CASE 0 7.49 67
  107. 94011 ORGANIC_BANANAS 1 0.99 56.3
  108. older94011 ORGANIC_BANANAS 1 0.99 56.3
  109. closed94011 ORGANIC_BANANAS 1 0.99 56.3
  110. 94011 ORGANIC_BANANAS 1 0.99 56.3
  111. 94011 ORGANIC_BANANAS 1 0.99 56.3
  112. 94011 ORGANIC_BANANAS 1 0.99 56.3
  113. 94011 ORGANIC_BANANAS 1 0.99 56.3
  114. 94011 ORGANIC_BANANAS 1 0.99 56.3
  115. 94011 ORGANIC_BANANAS 1 0.99 56.3
  116. 94011 ORGANIC_BANANAS 1 0.99 56.3
  117. 94011 ORGANIC_BANANAS 1 0.99 56.3
  118. 94011 ORGANIC_BANANAS 1 0.99 56.3
  119. 94011 ORGANIC_BANANAS 1 0.99 56.3
  120. 94011 ORGANIC_BANANAS 1 0.99 56.3
  121. 94011 ORGANIC_BANANAS 1 0.99 56.3
  122. 94011 ORGANIC_BANANAS 1 0.99 56.3
  123. 94011 ORGANIC_BANANAS 1 0.99 56.3
  124. 94011 ORGANIC_BANANAS 1 0.99 56.3
  125. 94011 ORGANIC_BANANAS 1 0.99 56.3
  126. 94011 ORGANIC_BANANAS 1 0.99 56.3
  127. 94011 ORGANIC_BANANAS 1 0.99 56.3
  128. 94011 ORGANIC_BANANAS 1 0.99 56.3
  129. 94011 ORGANIC_BANANAS 1 0.99 56.3
Add Comment
Please, Sign In to add comment