Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. //Author: Nicholas Berard, ndb5213, 10.07.15 7:25am
  2. //Class: CMPSC121
  3. //Experiment:
  4. //File: E:\College\Programming\CMPSC121\
  5. //Purpose:
  6.  
  7. /*I certify that, this program code is my work. Others may have
  8. assisted me with planning and concepts, but the code was written,
  9. solely, by me.
  10.  
  11. I understand that submitting code which is totally or partially
  12. the product of other individuals is a violation of the Academic
  13. Integrity Policy and accepted ethical precepts. Falsified
  14. execution results are also results of improper activities. Such
  15. violations may result in zero credit for the assignment, reduced
  16. credit for the assignment, or course failure
  17. */
  18.  
  19. #include <iostream>
  20. #include <fstream>
  21. #include <string>
  22.  
  23. using namespace std;
  24. int main()
  25. {
  26. ifstream fileIn;
  27. fileIn.open("parts.txt");
  28. if (fileIn.fail())
  29. cout << "Error, file not found!";
  30.  
  31. string partN;
  32. char type;
  33. int quan = 0;
  34. int aCou = 0;
  35. int bCou = 0;
  36. int cCou = 0;
  37. int dCou = 0;
  38. double price = 0;
  39. double aTot = 0;
  40. double bTot = 0;
  41. double cTot = 0;
  42. double dTot = 0;
  43.  
  44. cout << "------------------------Inventory Report--------------------------" << endl;
  45.  
  46. while (fileIn >> partN >> type >> quan >> price)
  47. {
  48. if (type == 'A')
  49. {
  50. aCou += quan;
  51. aTot += quan * price;
  52. }
  53. if (type == 'B')
  54. {
  55. bCou += quan;
  56. bTot += quan * price;
  57. }
  58. if (type == 'C')
  59. {
  60. cCou += quan;
  61. cTot += quan * price;
  62. }
  63. if (type == 'D')
  64. {
  65. dCou += quan;
  66. dTot += quan * price;
  67. }
  68. }
  69.  
  70. cout << "A parts Count: " << aCou << " Value of Inventory: " << aTot << endl;
  71. cout << "B parts Count: " << bCou << " Value of Inventory: " << bTot << endl;
  72. cout << "C parts Count: " << cCou << " Value of Inventory: " << cTot << endl;
  73. cout << "D parts Count: " << dCou << " Value of Inventory: " << dTot << endl;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement