Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <fstream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- using namespace std;
- class Revenue{
- private:
- string divNum, divName;
- int numEmployees;
- double totalSales, totalCosts, profit, costPerEmp;
- public:
- static int numDiv, qtrNum;
- void storeInfo(string dNum, int eNum, string dName, double tSales, double tCosts);
- static void modifynumDiv(int totalDivisions);
- static void modifyqtrNum(int qNum);
- string setDivNum(string dNum){
- divNum = dNum;
- return divNum;
- }
- int setNumEmployees(int eNum){
- numEmployees = eNum;
- return numEmployees;
- }
- string setDivName(string dName){
- divName = dName;
- return divName;
- }
- double setTotalSales(double tSales){
- totalSales = tSales;
- return totalSales;
- }
- double setTotalCosts(double tCosts){
- totalCosts = tCosts;
- return totalCosts;
- }
- double getProfit(double tSales, double tCosts){
- double profit = ((tSales) - (tCosts));
- return profit;
- }
- double getCostPerEmp(int eNum, double tCosts){
- double costPerEmp = ((tCosts) / (numEmployees));
- return costPerEmp;
- }
- };
- void Revenue::modifynumDiv(int totalDivisions){
- numDiv = totalDivisions;
- }
- void Revenue::modifyqtrNum(int qNum){
- qtrNum = qNum;
- }
- void Revenue::storeInfo(string dNum, int eNum, string dName, double tSales, double tCosts){
- divNum = dNum;
- numEmployees = eNum;
- divName = dName;
- totalSales = tSales;
- totalCosts = tCosts;
- }
- int Revenue::numDiv = 0;
- int Revenue::qtrNum = 0;
- int main(){
- ofstream outputFile;
- outputFile.open("cop2224_proj2.xml");
- Revenue rev;
- char proceed;
- int numDivisions, qNum, eNum, totalDivisions = 0;
- string dNum, dName;
- double tSales, tCosts;
- outputFile << "<Revenue>" << endl;
- //Intro
- cout<< "Welcome to the Revenue Entry Program. \n";
- cout<< "The next few prompts will ";
- cout<< "take you though revenue entry based on desired number of reporting divisions. \n";
- cout<< "After you enter one record you will ";
- cout<< "have the option to enter another or exit." << endl;
- cout<< "Would you like to continue? Enter 'Y' or 'N': ";
- cin >> proceed;
- // Exit if user chooses not to proceed
- for (;(proceed =='Y') || (proceed == 'y');){
- // Display the prompts and capture input
- cout << "Revenue Entry.\n";
- cout << "What Quarter are Your Recording Information for?: ";
- cin >> qNum;
- cout << "How Many Divisions would you like to process revenue for?: ";
- cin >> numDivisions;
- Revenue *divisions = new Revenue[numDivisions];
- //Get the Revenue information for each division.
- cout << "Enter the Division information below. \n";
- for (int count = 0; count < numDivisions; count++){
- while(proceed =='Y' || proceed == 'y'){
- cout << "Division Name: ";
- cin >> dName;
- rev.setDivName(dName);
- cin.ignore();
- cout << "Enter the 4 Digit Division Number: ";
- cin >> dNum;
- while (dNum.length() < 4 || dNum.length() >= 5){
- cout << "Error, Division number must be 4 digits only, try again: ";
- cin >> dNum;
- }
- rev.setDivNum(dNum);
- cout << "Enter number of employees in the Division: ";
- cin >> eNum;
- while (eNum <= 0){
- cout << "Error, no negative numbers may be entered and each Division must have at least one employee." << endl;
- cout << "Enter number of employees in the Division: ";
- cin >> eNum;
- }
- rev.setNumEmployees(eNum);
- cout << "Enter total sales for this Division: ";
- cin >> tSales;
- while (tSales <= 0){
- cout << "Negative numbers and 0 not accepted, try again: ";
- cin >> tSales;
- }
- rev.setTotalSales(tSales);
- cout << "Enter total costs for this Division: ";
- cin >> tCosts;
- while (tCosts <= 0){
- cout << "Negative numbers not accepted, try again: ";
- cin >> tCosts;
- }
- rev.setTotalCosts(tCosts);
- totalDivisions += 1;
- //Output Entries
- outputFile <<"<Division>" << endl
- << "<DivisionName>" << dName << "</DivisionName>" << endl
- << "<DivisionNumber>" << dNum << "</DivisionNumber>" << endl
- << "<NumberofEmployees>" <<eNum << "</NumberofEmployees>" << endl
- << "<TotalSales>" << fixed << setprecision(2) << tSales << "</TotalSales>" << endl
- << "<TotalCosts>" << fixed << setprecision(2) << tCosts << "</TotalCosts>" << endl
- << "<Profit>" << fixed << setprecision(2) << rev.getProfit(tSales, tCosts) << "</Profit>" << endl
- << "<CostPerEmployee>" << fixed << setprecision(2) << rev.getCostPerEmp(eNum, tCosts) << "</CostPerEmployee>" << endl
- <<"</Division>" << endl;
- cout << "Record Saved.\n";
- cout << "Do You Want to enter another record? 'Y' or 'N': ";
- cin >> proceed;
- }
- }
- Revenue::modifyqtrNum(qNum);
- Revenue::modifynumDiv(totalDivisions);
- outputFile << "<Quarter>" << Revenue::qtrNum << "</Quarter>" << endl
- << "<TotalDivisionsRecorded>" << Revenue::numDiv << "</TotalDivisionsRecorded>" << endl
- << "</Revenue>";
- }
- cout << "No additional records added. \n";
- outputFile.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement