Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- ifstream infile;
- ofstream outfile;
- double retailValue = 0;
- double baseValue = 0;
- double comission = 0;
- int employeeID = 0;
- int count = 0;
- double totalSales = 0;
- double totalComission = 0;
- int previousID = 0;
- double employeeComissions = 0;
- double employeeSales = 0;
- infile.open("carsales.dat");
- outfile.open("carsales.txt");
- outfile << "WEEKLY SALES REPORT: ";
- outfile << endl
- << "Employee ID / Retail Value / Comission";
- outfile << fixed << showpoint << setprecision(2);
- while (!infile.eof()) {
- infile >> employeeID >> retailValue >> baseValue;
- if (employeeID >= 100 && employeeID <= 999) {
- count++;
- }
- if ((baseValue * .3) > 100) {
- comission = baseValue * .3;
- }
- else
- comission = 100;
- if (previousID && previousID != employeeID) {
- outfile << endl
- << "Totals for Employee ID: " << previousID << ' ' << "Total Comission: " << employeeComissions << ' ' << "Total Retail Value: " << employeeSales;
- employeeComissions = 0;
- employeeSales = 0;
- }
- outfile << endl
- << employeeID << ' ' << retailValue << ' ' << comission << ' ';
- totalSales += retailValue;
- totalComission += comission;
- previousID = employeeID;
- employeeComissions += comission;
- employeeSales += retailValue;
- }
- outfile << endl
- << "Totals for Employee ID: " << employeeID << ' ' << "Total Comission: " << employeeComissions << ' ' << "Total Retail Value: " << employeeSales;
- outfile<<endl;
- outfile << endl
- << "Records: " << count;
- outfile << endl
- << "Total Sales: " << totalSales;
- outfile << endl
- << "Total Comission: " << totalComission;
- infile.close();
- outfile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement