Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include <string>
- #include <sstream>
- using namespace std;
- void readFile(ifstream &inputFile);
- int main()
- {
- ifstream inputFile;
- inputFile.open("QuarterlySalesFile.txt");
- if (!inputFile) {
- cout << "Unable to open file";
- }
- else
- readFile(inputFile);//arguments
- inputFile.close();
- return 0;
- }
- void readFile(ifstream &inputFile)//parameters
- {
- int iD,targetId=0,i=0,x=0;
- int monthI, month[12], amntTotal=0;
- float amountofSale, amnt=0, accountTotal=0;
- float commissionRate=0.26;
- string months[12]{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
- //targetId=iD;
- while (inputFile >> iD >>monthI>>amountofSale)
- {
- if(x==0)
- {
- cout<<iD<<"\t"<<months [monthI-1]<<"\t"<<""<<amountofSale<<endl;
- x++;
- }
- if(iD!=targetId)
- {
- amnt+=amountofSale;
- cout<<iD<<"\t"<<months [monthI-1] <<"\t"<<amountofSale <<endl;
- iD=targetId;
- }
- }
- cout<<amnt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement