Transcribed TextTranscribed Text

Program Assignment Overview The goal of this project is to become comfortable with defining your own class and to leverage the power of object-oriented programming to analyze data. Background Analyzing a company’s sales data to learn more about their sales and customers’ buying habits enables retailers to make good business decisions. Sales data can be analyzed by category, sku, customer, etc. and by various sales metrics to help a company make sense of the huge amount of data to be analyzed. Some questions that can be answered are…. 1. What was the average cost of a transaction? 2. What are the minimum and maximum sales prices? 3. What are the purchasing patterns by customer and category. Project Specifications Your project will consist of two programmer defined classes: • A Sales class that represents information and processing for one sales transaction. • A CompanySales class that represents information and processing for all the sales of a company. Sales class: Total of 25 points Attributes: Customer number Category Quantity Unit Price Extended Price Methods: A constructor that receives values for all the attributes and initializes the attributes with those values. 5 points Gets and Sets for all attributes 15 points Display method to display all the attributes, nicely formatted with labels 5 points CompanySales Total of 45 points Attributes of the class: CompanyName CompanyAddress A vector of Sales objects the containing sales data Methods of the class: • Constructor that receives the company name, company address, and filename containing the sales data. The constructor should initialize the name and address attributes of the class, read the file, creating a Sales object and adding it to the vector for each line in the file. 10 points • Set and get methods for company name and address. 5 points • A display method that displays a nicely formatted table containing the company name and address on one line followed by the sales data for each object in the vector. • The following data analysis methods should also be included: o Stats method that receives a string (UnitPrice or ExtPrice) calculates and displays the average, min, and max value of the particular column from the vector of Sales objects 10 points o Sort method that will sort the vector using a selection sort on account number and return a vector of Sales objects sorted by account number 10 points o groupSum method that receives the sorted vector of Sales objects and displays the total of the extended price grouped by account number. It should also display the account number with the highest total of extended prices and that total. 10 points Notes and hints: 1. Your class notes as well as zyBook Figure 10.7 will help you with your class design. For simplicity sake, zyBooks does not divide the interface from the implementation; however, in this course you are REQUIRED to have a .h file (the interface) and a .cpp file (the implementation) for each class definition. 2. You should code and test the Sales class immediately (in your lab class after Fall break). Firstly, write your Sales.h and compile it. Then write your Sales.cpp and compile it. To completely do a unit test on the class, you can create a simple main driver (program4.cpp) that creates a Sales object and calls all the sets, gets and display methods to ensure their proper working. 3. Next, you should code the CompanySales class containing only its attributes, the constructor and the display method (NO OTHER METHODS). You should incrementally test the CompanySales class by writing a main driver (program4.cpp) that creates a CompanySales object (which calls the constructor) and the display method to make sure the constructor properly read the file and populated the vector with sales objects. 4. After steps 1-3 have been completed successfully, write each data analysis method, one at a time, testing completely before going to the next one. 5. When you sort the vector of Sales objects, you will have to compare the account number (so you will use the get method to examine it); however, the entire element (an object) has to be swapped in the sort, not just one column. 6. Your program4.cpp should fully test the Sales and CompanySales class. 10 points

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

* File:   CompanySales.cpp
* Author:

#include "CompanySales.h"
#include "Sales.h"
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <fstream>
#include <cfloat>
using namespace std;

CompanySales::CompanySales(string companyName,
       string companyAddress, string fileName) {
    this->companyAddress = companyAddress;
    this->companyName = companyName;
    fstream in;, ios::in);
    if (in.is_open()) {
       // reading csv fle         
       int customerNumber;
       string category;
       int quantity;
       double unitPrice;
       double extendedPrice;
       char comma;
       Sales sale;
       string line, word;

       // read head line
       getline(in, line);
       // read a line
       while (getline(in, line)) {
            //            cout << line << "\n";
            // turn string to stream
            stringstream s(line);

            // split by comma
            getline(s, word, ',');
            customerNumber = atoi(word.c_str());

            getline(s, category, ',');

            getline(s, word, ',');
            quantity = atoi(word.c_str());

            getline(s, word, ',');
            unitPrice = atof(word.c_str());

            getline(s, word);
$50.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats