Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Model the following data in C++: data_v1.csv Be sure to create an effective and efficient class structure for the data. This will be part of

  1. Model the following data in C++: data_v1.csv
    1. Be sure to create an effective and efficient class structure for the data. This will be part of your grade. The grading rubric is below.
    2. Take note that the reports have some internal structure and behavior as well. Create an effective and efficient object hierarchy for your reports.
    3. DESIGN NOTES:
      1. IMPORTANT: Give this first step some serious, deep thought before you jump into writing code.
        1. Draw out all your objects. You might want to use UML; it's powerful and compact. Use whatever works for you, but draw it out and then use your diagrams as you are writing your coding.
        2. List all your instance variables, methods, operators, comparators, and iterators.
        3. Decide what should be private, public or protected?
        4. Think about the constructors, setters, and getters you will need. Will you overload any of them? Will you override any methods?
        5. Employ multiple inheritances, overloading and overriding, as appropriate.
        6. Are there any virtual functions? Any pure virtual functions?
        7. I will be using different datasets to grade your project, so be thinking about general coding concerns and expected edge cases. For example, what does your code do with an empty file, a non-existent file, a file with one line, a file where every line is repeated twice.
        8. Are there any other important questions to answer at this stage?
      2. Be sure to reread this first section after you have read through the entire assignment instructions once.
      3. And then read it once again after you complete your initial design, to make sure you have handled everything in your design for the assignment.
  2. Read the data from the CSV file into the internal data structure you have designed.
    1. DATA NOTES:
      1. CSV stands for Comma Separated Values, and it is a very common file format. The only commas in this data file are the commas (delimiters) that separate the different fields (columns) on each record (row) of data.
      2. I am supplying everyone with a working piece of code readCVS.cpp that reads CSV files so that no one gets stuck on this early task. It's crude, but it does work on the supplied data file. You may use any of this code in your project, so long as you properly cite it at the end of your main.cpp file.
      3. Use any ADT containers you would like to manage the data. I would expect to see at least one.
      4. Handle problems in the input data via exceptions. The supplied dataset will include the following errors, and there may be others:
        1. Missing field value(s), aka incomplete data report a warning on input, then ignore this row. (Missing data will appear as two or more consecutive commas on one line (row) in the CSV file.)
        2. Duplicate rows - report a warning on input, then ignore these as well.
      5. You might want to get things working first without handling the input exceptions (try-catch-throw). Partial credit will be awarded in that case. But note that the reports with incorrect data will be wrong. GIGO
  3. Create the following 3 data reports:
    1. An "Employee Phone Number List" Report that lists: ID, LastName, FirstName, and PhoneNumber. Sorting is optional.
    2. An "Input Data Quality Report" that lists all the data, in the order it was input. It follows the input data with 3 error sections that describe the data quality problems that may have occurred. You might want to do this report after everything else is working.
      1. While listing the data that was read, print a single line with a single "*" (asterisk) to indicate when there was a problem with a row of input data. You can include a description of the problem after the asterisk.
      2. At the end of the "Input Data Quality Report", provide 3 "Data Quality Exceptions Sections":
        1. A list of any "Duplicates" (duplicates should be ignored as data).
          1. Records are considered duplicates if the ID is duplicated.
          2. List each duplicated original input line in this section.
          3. Summarize this section with the "Total Count of Duplicate Records".
        2. A list of any "Incomplete Records" incomplete (these should be ignored as data).
          1. Records are considered incomplete if any field is missing a value.
          2. Print each incomplete record by printing the original input line in this section.
          3. Summarize this section with the "Total Count of Incomplete Records".
        3. Finally, in an " Exceptions Section Summary", list the "Total Error Count" (the sum of 1 and 2 above), and "Total Good Records Count".
      3. This "Input Data" report can be requested at any time by the user. (See #6 below.)
      4. Be sure to include a data header row in the appropriate places in this multi-part report.
    3. For the 3rd report, design your own report that takes advantage of your object-oriented design.
    4. REPORT NOTES:
    1. All reports should have:
      1. A Title,
      2. A header row (column names),
      3. Followed by all the report data.
      4. At the end of every report, you should print a message indicating how many "Total Rows" were in the report. Do not count the header in this count.
    2. Reports should be written to "court".
    3. You should consider creating a method called InfoToString to create the output strings that will be printed in each report.
      1. Use this method to create the strings (lines) that you will print out in all the reports.
      2. See if you can also use some form of this method to create the "Column Header" line for each report.
      3. Then each PrintReport method just prints out all these strings, each on a separate line, followed by the report line total count.
    4. Ideally, the columns of each report will line up vertically.
      1. You might choose to get this "columnization" to work after you have everything else working unless not having things in columns makes your code debugging too difficult. [A hint on how to do this is in the read CVs.cpp example file.]
    5. The Employee ID is expected to be unique. You will enforce this by ignoring rows with duplicate IDs. Employee names and locations may not be unique.
    6. IMPORTANT: CLion has a default 120 character limit on output. See the "Removing CLion's 120 character output limit" section below on how you can remove that limit so your reports will display properly.
  4. Create the following 3 analytical reports:
    1. An "Employee Cluster Report" shows the number of employees living in each ZipCode. The report lists the ZipCode, City, State, and EmployeeCount.
      1. List each ZipCode only once.
      2. Sorting by ZipCode is optional.
      3. This report might be used to help decide where to build the next company office building.
    2. An "Employee Pay Raise Report" shows EmployeeName, Salary, NewSalary, and RaiseAmount, where each employee gets a 2.5% raise.
      1. Write a CalculateEmployeeRaise method that takes one double argument, the percent raise. Use it to give each employee a raise.
      2. Note that NewSalary is a data element not in the original data file.
      3. Sorting the report by the RaiseAmount is optional.
      4. Be sure to include the employee's full name in the report.
    3. An "Employee Regional Raises Report", showing the total of the raises by ZipCode. Sorting is optional.
  5. Create 2 Unit Tests in a simple Test Harness.
    1. Test01: Test that you get the correct number of rows printed in one of your reports. Provide a small test dataset (in the code), create the objects that would be created if this data had been read in, and then check that the resulting total number of rows that would be printed is correct. Return an appropriate value to the test harness.
    2. Test02: Test the analysis of one of your analytic reports by providing a small test dataset (in the code), build your objects from it, generate the report, and check the result of the analysis. The "Employee Cluster Report" or the "Employee Regional Raises Report" are good candidates for this test, as they each have a summary number you can check in your test. Return an appropriate value to the test harness.
    3. TEST NOTES:
      1. Creating good test cases involves both good coding design and good test data choices.
      2. Ideally, these test cases should not read from files. They should have all their data in the code. But its ok to implement your test cases that read from specific test data files.
      3. It is the test harness that executes the tests. The test harness then takes the result from a test case being called and prints out an appropriate test result message, based on the result of the test.
      4. Add any additional test cases that you think are appropriate.
  6. Finally, orchestrate everything with the main menu loop that asks the user what they would like to do.
    1. Determine the input file name to use:
      1. Provide an option that will read the file: data_v1.csv
      2. Provide an option for the user to type in the filename to be read. You might find this useful in your own testing.
    2. Determine the user's desired processing:
      1. Allows the user to select any report, any test case, or Quit.
      2. Provide an "All" option that runs all the reports and all test cases.
      3. Allow the user to read data from a different file (see 6.a.ii above).
      4. Be sure to print out all the available menu options at least once.
  7. Deliverables:
    1. A single compressed .zip file folder containing the source code files and data files only.
      1. Don't just zip the whole project folder. It confuses CLion.
      2. Include data_v1.csv and any additional .csv files that you created.
    2. Please label the zip folder in this format: [LastName]_[FirstName]_final.zip
      • For example: cameron_andy_final.zip
    3. Your project will be graded in CLion, not zyBooks. It needs to compile and run in CLion.
    4. Submit the file on Canvas by the deadline.
      • Only the last submission on Canvas will be graded
    5. A series of automated tests will be used to grade your code's functionality (Items 2, 3, 6, and 7 from the rubric above). Here are the menu selectors that the grading test harness will use when it automatically runs and tests your code:
      • F Read File: data_v1.csv
      • I Specify the Input file name (requires a second input (string))
      • N Phone Number List
      • D Data Quality Report
      • Y Your Custom Report
      • C Employee Cluster Report
      • P Employee Pay Raise Report
      • R Regional Raises Report
      • S Sequence of All Reports (order: N, D, Y, C, P, R)
      • 1 Test01
      • 2 Test02
      • T All Tests (order: 1, 2)
      • A All Reports and All Tests (order: S, T)
      • Q Quit
    • Don't be overwhelmed by this list. Start small and add functionality as you go. This is the hallmark of good software engineering.
  8. Remember, only your last Canvas submission will be graded, so you can submit your project to Canvas multiple times if you would like. You might consider these submissions to be check-ins when you get certain parts to work. Again, only the last submission will be graded.
  9. In school, and in life, be sure to understand the task in front of you fully, and then prioritize your efforts to maximize your results (in this case your grade).

    Remember to do your own work and to cite everything appropriately. If you talk to anyone about the project, be sure to document it. Discussing design alternatives is fine (if documented); copying or sharing code is not ok; except that using the supplied readCSV.cpp is allowed. Remember, the "double zero" penalty (as described in the syllabus) is in effect.

    Resources:

  10. Data file: data_v1.csv

image text in transcribed

  1. Sample code: readCSV.cpp

image text in transcribed

image text in transcribed

image text in transcribed

  1. Removing CLion's 120 character output limit:

  2. CLion has an (unexpected) character output limit that defaults to 120 characters. To remove it, so your reports look correct, do the following:
    1. Go to: Help -> Find Action -> Registry
    2. Unclick the box next to: run.processes.with.pty
    3. Click: Close
  3. See https://stackoverflow.com/questions/52268686/how-can-i-expand-the-max-width-of-the-run-tool-window-in-clion-intellij (Links to an external site.) for more information.
KNmmx0000mm FE000 OOOOOOZE IX00 2WD BRBBS $ 99 2 2 eggass KWMANY LEE 0 FFF SOR RRS #include #include #include #include #include #include using namespace std; // CSC2430 Data Structures I // Prof Andy Cameron 11 (c) 2021 // Reading a csv (Comma Separated Values) file example // You may use any of this code in your final project, so long as you properly cite at the end of your main.cpp file. int Readcsv(string filename, string &header, vector& records) { ifstream inFS; // input file stream string record; // one complete input line (row) int rows=0; // row count does not include the header row // Open file infs.open(filename); cout > record; if (!inFs.fail()) { records.push_back(record); // store the input (complete line) rows++; // count the number of rows } } // close file when done reading inFs.close(); return rows; // return the number of rows read } int main() { string header; vector lines; int rows; std::stringstream lineStream(header); // used to read the field (column/cell) data from the data line (row) string string colon, colo2, colo3, colo4, colo5, colo6, color, colo8, colo9, collo, colii, col12, col13, col14, col15, col16; string id, prefix, first, mi, last, gender, email, dob, hired, Salary, phone, city, state, zip, region, user; // WARNING: This might not be the exactly match the field names and sequence of the data in your file. rows = Readcsv"../data_v1.csv", header, lines); // put the file data.csv in the same directory as main.cpp cout #include #include #include #include #include using namespace std; // CSC2430 Data Structures I // Prof Andy Cameron 11 (c) 2021 // Reading a csv (Comma Separated Values) file example // You may use any of this code in your final project, so long as you properly cite at the end of your main.cpp file. int Readcsv(string filename, string &header, vector& records) { ifstream inFS; // input file stream string record; // one complete input line (row) int rows=0; // row count does not include the header row // Open file infs.open(filename); cout > record; if (!inFs.fail()) { records.push_back(record); // store the input (complete line) rows++; // count the number of rows } } // close file when done reading inFs.close(); return rows; // return the number of rows read } int main() { string header; vector lines; int rows; std::stringstream lineStream(header); // used to read the field (column/cell) data from the data line (row) string string colon, colo2, colo3, colo4, colo5, colo6, color, colo8, colo9, collo, colii, col12, col13, col14, col15, col16; string id, prefix, first, mi, last, gender, email, dob, hired, Salary, phone, city, state, zip, region, user; // WARNING: This might not be the exactly match the field names and sequence of the data in your file. rows = Readcsv"../data_v1.csv", header, lines); // put the file data.csv in the same directory as main.cpp cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago