Thursday, August 8, 2013

Trading Company Division Sales For Each Quarter CPP

Download Solution from here
A trading company has three divisions, each responsible for sales to different locations. Design a DivSales class that keeps the sales data for a division, with the following members:
  • An array with four elements for holding four quarters of sales figures for the division.
  • A private static variable for holding the total corporate sales for all divisions for the entire year
  • A member function that takes four arguments, each assumed to be the sales for a quarter. The value of the arguments should be copied into the array that holds the sales data. The total of the four arguments should be added to the static variable that holds the total yearly corporate sales.
  • A function that takes an integer argument within the range of 0-3. The argument is to be used as a subscript into the division quarterly sales array. The function should return the value of the array element with that subscript.
Write a program that creates an array of three DivSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data are entered, the program should display a table showing the division sales for each quarter. The program should then display the total corporate sales for the year.
  • For this question, name your class DivSales. For example, my class would be named: LeongLeeDivSales.
  • Use inline member functions for all the method functions mentioned.
  • You need to submit the following files:
1. DivSales.h: Specification (and inline member functions) for class and other functions should be in this .h file
2. DivSales_Demo.cpp : You need to write a separate program to test the class. In other words, main() is here.
Important: If you do not put to the above mentioned fields (class name and filename), you will get 0 point for the question.

SAMPLE RUN
Your output should look similar to the following. Things in bold are typed by the user.
Enter sales data for Division 1
Quarter 1: 1000
Quarter 2: 2000
Quarter 3: 3000
Quarter 4: 4000
Enter sales data for Division 2
Quarter 1: 2100
Quarter 2: 3200
Quarter 3: 4200
Quarter 4: 5200
Enter sales data for Division 3
Quarter 1: 6000
Quarter 2: 7000
Quarter 3: 8000
Quarter 4: 9000
================================
--- Report ---
Sales for Division 1
Quarter 1: $1000.00
Quarter 2: $2000.00
Quarter 3: $3000.00
Quarter 4: $4000.00
Sales for Division 2
Quarter 1: $2100.00
Quarter 2: $3200.00
Quarter 3: $4200.00
Quarter 4: $5200.00
Sales for Division 3
Quarter 1: $6000.00
Quarter 2: $7000.00
Quarter 3: $8000.00
Quarter 4: $9000.00
Press Enter to Continue.
Total Corporate Sales: $54700.00

No comments:

Post a Comment