Project Assignment
Course: COSC 1436 (C++)
Term: Mode:
Instructor: Abass Alamnehe
Purpose: Project II Assignment: Aggregate Sales Data
Requirement
▪ Use Visual Studio.
▪ To submit, package your work in Visual Studio project with ZIP format.
▪ Submit your work on http:
eagleonline.hccs.edu (Eagle Online) by due date.
Resources
Visual Studio Site
https:
visualstudio.microsoft.com/free-developer-offers/
Getting Started with Visual Studio
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio-2017-
17798?l=9oIw0FD6D_ XXXXXXXXXX
C++ Coding Convention
https:
google.github.io/styleguide/cppguide.html
Digital & Information Technology
Houston Community College
https:
visualstudio.microsoft.com/free-developer-offers
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio XXXXXXXXXX?l=9oIw0FD6D_ XXXXXXXXXX
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio XXXXXXXXXX?l=9oIw0FD6D_ XXXXXXXXXX
Project Aggregate Data
Learning Outcomes
At the end of the project, the expected learning outcomes:
▪ Analyze and develop solution.
▪ Use loops to process repeated input stream.
▪ Perform file input/output operations with multiple files.
▪ Declare initialized variables and objects.
▪ Use proper data types to store and process.
▪ Write expressions to solve problems.
▪ Integrate e
or checking mechanism in the code.
Project Requirement
The purpose of this project is to process sales data and produce an aggregated result. The sales data comes from
four cities--nameply “austin.txt”, “dallas.txt”, “houston.txt”, and “san_antonio.txt”. The objective is to aggregate
the data from all the cities and produce the total sales of each product.
▪ The product list and its order from each city is the same; however, the sales figure is different.
▪ There are four cities represented by “austin.txt”, “dallas.txt”, “houston.txt”, and “san_antonio.txt”. And
these files are furmished along with the project assignment.
▪ There are eight products with two fields--“Product” and “Sales”.
▪ One of the file “austin.txt” is provided below.
PRODUCT SALES
CPU XXXXXXXXXX
Mothe
oard XXXXXXXXXX
Case XXXXXXXXXX
Storage XXXXXXXXXX
Monitor XXXXXXXXXX
Graphics_Cards XXXXXXXXXX
Laptop XXXXXXXXXX
PC XXXXXXXXXX
▪ Again, the purpose is to read each file and produce the total of eah product in the list.
▪ The result should be displayed on the console and printed into an output file called “report.txt”.
Helpful Hint
It would be helpful considering the folliwng points.
▪ The four files provided along with the project should be included in the Visaul Studio project you create where
the “.cpp” file is located. There is no need to create the files and edit the input data. Once included, the files
will be accessible directly as shown below.
ifstream inFile("austin.txt");
▪ Decalring global variables for each product item might be easier.
▪ When you process the input files, you should read the first line and discard it since it is a header.
Resoruces
Microsoft Input and Output
https:
docs.microsoft.com/en-us/cpp/c-runtime-li
ary/input-and-output?view=vs-2019
fstream>
https:
docs.microsoft.com/en-us/cpp/standard-li
ary
asic-fstream-class?view=vs-2019
iostream>
https:
docs.microsoft.com/en-us/cpp/standard-li
ary/iostream?view=vs-2019
Requirement
1. Use the Visual Studio IDE to edit and build the program.
2. Please use the Google C++ Coding Convention provided below.
https:
google.github.io/styleguide/cppguide.html
3. Ensure that the source code is formatted and documented properly.
4. Submit the Visual Studio project of your work in zip format at http:
eagleonline.hccs.edu
https:
docs.microsoft.com/en-us/cpp/c-runtime-li
ary/input-and-output?view=vs-2019
https:
docs.microsoft.com/en-us/cpp/standard-li
ary
asic-fstream-class?view=vs-2019
https:
docs.microsoft.com/en-us/cpp/standard-li
ary/iostream?view=vs-2019
https:
google.github.io/styleguide/cppguide.html
http:
eagleonline.hccs.edu
Project Assignment I
Course: COSC 1436 (C++)
Term: Mode: F2F
Instructor: Abass Alamnehe
Purpose: Process COVID Data
Requirement
▪ Use Visual Studio.
▪ To submit, package your work in Visual Studio project with ZIP format.
▪ Submit your work on http:
eagleonline.hccs.edu (Eagle Online) by due date.
Resources
Visual Studio Site
https:
visualstudio.microsoft.com/free-developer-offers/
Getting Started with Visual Studio
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio-2017-
17798?l=9oIw0FD6D_ XXXXXXXXXX
C++ Coding Convention
https:
google.github.io/styleguide/cppguide.html
Digital & Information Technology
Houston Community College
https:
visualstudio.microsoft.com/free-developer-offers
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio XXXXXXXXXX?l=9oIw0FD6D_ XXXXXXXXXX
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio XXXXXXXXXX?l=9oIw0FD6D_ XXXXXXXXXX
Project Objective
The tasks for this project involve reading a set of data from an input file, calculating percentage, determining the
population from the given data, and displaying the result to the console output.
The input data is obtained from CDC COVID Data Tracker at the following website. By now, the actual numbers
should change, so what is provided along with this project is an outdated data.
https:
www.cdc.gov/covid-data-tracke
#cases
For the purpose of this project, the columns (fields) that were selected include State, Total Case, Total Death, and
Total Death per 100k population. The file name for the data is “cdc_covid_data.txt”.
You are to develop a C++ program to process the data and performing the following specific tasks.
▪ Read the data from the input file “cdc_covid_data.txt”. There are four fields-- State, Total Case, Total
Death, and Total Death per 100k population.
▪ Calculate the percentage of the death rate per state.
▪ Determine the population of each state from the given data.
▪ Display the result on the console screen.
The input data format is shown below partially.
State Total Cases Total Death_100k
AK XXXXXXXXXX
AL XXXXXXXXXX
AR XXXXXXXXXX
AS XXXXXXXXXX
AZ XXXXXXXXXX
CA XXXXXXXXXX
CO XXXXXXXXXX
CT XXXXXXXXXX
DC XXXXXXXXXX
DE XXXXXXXXXX
FL XXXXXXXXXX
FSM XXXXXXXXXX
https:
www.cdc.gov/covid-data-tracke
#cases
The output should include the calculated result as shown below partially.
Project Learning Outcomes
At the end of the project, the expected learning outcomes:
▪ Analyze and develop solution.
▪ Write formatted code with proper documentation.
▪ Declare initialized variables and objects.
▪ Use proper data types for declarations.
▪ Write expressions to solve problems.
▪ Perform input/output operations on console.
▪ Perform file input/output operations.
▪ Integrate e
or checking mechanism in the code.
▪ Build, test, and run programs.
Note: Helpful code sample is provided along with this project assignment. The sample is in Visual Studio project
format as well as a plain source code.
State Total Cases Total Death Death_100k Death_100k % Population
AK XXXXXXXXXX700000
AL XXXXXXXXXX XXXXXXXXXX
AR XXXXXXXXXX XXXXXXXXXX
AS XXXXXXXXXX
AZ XXXXXXXXXX XXXXXXXXXX
CA XXXXXXXXXX XXXXXXXXXX
CO XXXXXXXXXX XXXXXXXXXX
CT XXXXXXXXXX XXXXXXXXXX
DC XXXXXXXXXX XXXXXXXXXX
DE XXXXXXXXXX XXXXXXXXXX
FL XXXXXXXXXX XXXXXXXXXX
FSM XXXXXXXXXX
Requirement
1. Use the Visual Studio IDE to edit and build the program.
2. Please use the Google C++ Coding Convention provided below.
https:
google.github.io/styleguide/cppguide.html
3. Ensure that the source code is formatted and documented properly.
4. Submit the Visual Studio project of your work in zip format at http:
eagleonline.hccs.edu
Note
Along with this project assignment, a code that demonstrates how to read data from an input file is provided. It
uses a different data set for the input file. The code sample is intended to be an example with best practices. It is
not however, designed to force you how you should design and solve the project.
There are two functions--processCOVIDData() and main(). The main function is where the program starts
execution. Without the main function, the program cannot run as a standalone application. The
processCOVIDData() function demonstrates that a problem should be divided into manageable smaller pieces
and use functions to solve them.
An input data stream could be a file, a network connection, or a standard input device, such as keyboard. C++
provides a set of li
aries to perform file input/output.
▪ In C++, a file must be represented by an ifstream object for any operation. Please note that in the C
programming language, a different li
ary is used.
▪ Reading is performed using the istream object.
▪ The ifstream class supports all built-in data types.
* Create an ifstream object to read data from an input file. */
ifstream inFile(inputFileName);
https:
google.github.io/styleguide/cppguide.html
http:
eagleonline.hccs.edu
▪ If a problem involves repeatedly reading data from a file, we should use a suitable type of loop. In the
example, a while loop is used to read the file.
o The loop repeats if the inFile object knows there is more data from the input stream.
o Each round reads and processes each line of data from the input file.
o Each field in the line is read one at a time using proper variable.
Read the input file by looping until the end of the file.
while ( !inFile.eof() ) {
Read county, total case, and total death.
inFile
county
totalCase
totalDeath;
Process the data here.
Write to output console screen
cout
setw(20)
left
county
setw(15)
totalCase
setw(15)
totalDeath
endl;
}
Project Assignment
Course: COSC 1436 (C++)
Term: Mode:
Instructor: Abass Alamnehe
Purpose: Project II Assignment: C++ Keywords
Requirement
▪ Use Visual Studio.
▪ To submit, package your work in Visual Studio project with ZIP format.
▪ Submit your work on http:
eagleonline.hccs.edu (Eagle Online) by due date.
Resources
Visual Studio Site
https:
visualstudio.microsoft.com/free-developer-offers/
Getting Started with Visual Studio
https:
mva.microsoft.com/en-US/training-courses/getting-started-with-visual-studio-2017-
17798?l=9oIw0FD6D_ XXXXXXXXXX