IT2414-Information Technology Services
Assignments
Write a program that creates a Sales class. This program will read a space delimited file called “sales.dat”. The order of the fields is: salesNum, month, day, year, sales amount, vehicle type. Commission will be calculated. You will also need arrays for sales totals (4), commission totals(4) and vehicle type totals(3). All of these items will be in the class Sales.
Requirements
1.Your class will have the following private member variables:
int salesNum
int month
int day
int year
double saleAmt
char vehicle;
double commission
double salesTotal[4]
double comTotal[4]
double vehicleTotal[3]
2. The class will have the following public member functions:
Default constructor – to set the member variables to 0
With the arrays, which we have not worked with in a class, each element in the array must be initialized to zero. For example: salesTotal[0] = 0.00;, then for 1,2,3 for all 3 of the arrays.
headings – as shown on the output below.
processdata – open the file, check to make sure it’s there, process all records until the end of the file.
calcCommission – a function to calculate the commission
12,000 and below 2%
12001 to 17000 4%
17001 to 25000 5%
25001 to 40000 6%
40001 and up 7%
printResults – a function to print the report. See output below.
calcTotals – a function to calculate the three different totals. The totals are to be put in 3 separate arrays. For example: salesNum 10 will go in salesTotal[0], salesNum 11 will go in salesTotal[1], etc. The comTotal array will work just like the salesTotal array. The vehicle array will be cars at element 0, trucks at element 1 and used at element 2. Many ifs in this function
printTotals – a function to print the Totals by Sales ID and the vehicle totals. In this function, to get Cars, Truck and Used to print out, you will need to put them in a string array.
string description[3] = {“Cars”, “Trucks”, “Used”};
You will use for loops to print the 2 different set of totals out. When printing out the vehicle totals, in the for loop you will use description[i] and it will get you the appropriate total for cars, trucks and used.
printResults, calcCommission and calcTotals will be called from processdata. The other functions will be called from main.