Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Author: Nicholas Berard, ndb5213, 10.07.15 7:25am
- //Class: CMPSC121
- //Experiment:
- //File: E:\College\Programming\CMPSC121\
- //Purpose:
- /*I certify that, this program code is my work. Others may have
- assisted me with planning and concepts, but the code was written,
- solely, by me.
- I understand that submitting code which is totally or partially
- the product of other individuals is a violation of the Academic
- Integrity Policy and accepted ethical precepts. Falsified
- execution results are also results of improper activities. Such
- violations may result in zero credit for the assignment, reduced
- credit for the assignment, or course failure
- */
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- ifstream fileIn;
- fileIn.open("parts.txt");
- if (fileIn.fail())
- cout << "Error, file not found!";
- string partN;
- char type;
- int quan = 0;
- int aCou = 0;
- int bCou = 0;
- int cCou = 0;
- int dCou = 0;
- double price = 0;
- double aTot = 0;
- double bTot = 0;
- double cTot = 0;
- double dTot = 0;
- cout << "------------------------Inventory Report--------------------------" << endl;
- while (fileIn >> partN >> type >> quan >> price)
- {
- if (type == 'A')
- {
- aCou += quan;
- aTot += quan * price;
- }
- if (type == 'B')
- {
- bCou += quan;
- bTot += quan * price;
- }
- if (type == 'C')
- {
- cCou += quan;
- cTot += quan * price;
- }
- if (type == 'D')
- {
- dCou += quan;
- dTot += quan * price;
- }
- }
- cout << "A parts Count: " << aCou << " Value of Inventory: " << aTot << endl;
- cout << "B parts Count: " << bCou << " Value of Inventory: " << bTot << endl;
- cout << "C parts Count: " << cCou << " Value of Inventory: " << cTot << endl;
- cout << "D parts Count: " << dCou << " Value of Inventory: " << dTot << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement