Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include <string>
  4. #include <sstream>
  5.  
  6. using namespace std;
  7. void readFile(ifstream &inputFile);
  8. int main()
  9. {
  10. ifstream inputFile;
  11.  
  12. inputFile.open("QuarterlySalesFile.txt");
  13. if (!inputFile) {
  14. cout << "Unable to open file";
  15. }
  16. else
  17. readFile(inputFile);//arguments
  18. inputFile.close();
  19. return 0;
  20. }
  21. void readFile(ifstream &inputFile)//parameters
  22. {
  23.  
  24. int iD,targetId=0,i=0,x=0;
  25. int monthI, month[12], amntTotal=0;
  26. float amountofSale, amnt=0, accountTotal=0;
  27. float commissionRate=0.26;
  28. string months[12]{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
  29.  
  30. //targetId=iD;
  31.  
  32. while (inputFile >> iD >>monthI>>amountofSale)
  33. {
  34.  
  35. if(x==0)
  36. {
  37. cout<<iD<<"\t"<<months [monthI-1]<<"\t"<<""<<amountofSale<<endl;
  38.  
  39. x++;
  40. }
  41.  
  42. if(iD!=targetId)
  43. {
  44. amnt+=amountofSale;
  45. cout<<iD<<"\t"<<months [monthI-1] <<"\t"<<amountofSale <<endl;
  46. iD=targetId;
  47. }
  48.  
  49.  
  50.  
  51. }
  52. cout<<amnt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement