Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code must be in C++. The purpose of this assignment is to read from a text file, and do some data analysis. You must

The code must be in C++.

image text in transcribed

The purpose of this assignment is to read from a text file, and do some data analysis. You must store your data into parallel arrays. Find your own data - you can have any dataset that interests you. There are many websites out there that have sample data you can use for this program. Please remember to cite your Sources.

Here is a picture of the website to see sample of data.

image text in transcribed

After completing this assignment you will be able to:

Open and read input from a file

Create parallel arrays that hold related pieces of information

Create and process two-dimensional arrays.

Check out Sample Assignment:

//This program reads from item.txt and prints the total calories of each item //items.txt has 3 columns of data - itemname that can have spaces, quantity - an int //and calories - an int //The program will read the data into a 2 dim char array and a 2 dim int array //It will calculate the total calories for each item and output to screen // #include #include #include #include

using namespace std;

//constant for number of items const int ITEMS = 10; //constant for number of characters const int MAXCHAR = 51;

//function prototypes bool openFile(ifstream &inFile); int loadData(ifstream &inFile, char items[][MAXCHAR], int otherData[][2]); void calcCalories(char items[][MAXCHAR], int otherData[][2], int count);

//main function that will call openFile, loadData and calcCalories int main() { ifstream inFile; int count = 0; char items[ITEMS][MAXCHAR]; int otherData[ITEMS][2] = {0}; if(!openFile(inFile)) { cout

//Name: openFile //Description: opens the file and returns true or false //input params: file stream variable //ouput: none //return: true or false // bool openFile(ifstream &inFile) { inFile.open("items.txt"); if(!inFile) { return false; } return true; }

//Name: loadData //Description: loads data from file //input params: char array for item names, and int array for other data (2 dim arrays) //output: none //return: count of the number of items. // int loadData(ifstream &inFile, char items[][MAXCHAR], int otherData[][2]) { int count = 0; //read the first item name outside to check if the file is empty inFile.getline(items[count], MAXCHAR, ';'); while(!inFile.eof()) { //read the next 2 int data into the int 2 dim array inFile >> otherData[count][0]; inFile.ignore(5, ';'); inFile >> otherData[count][1]; inFile.ignore(5, ' '); //increment count for next item count++; //read next item name from the next line in the text file inFile.getline(items[count], MAXCHAR, ';'); } return count; } //Name: calcCalories //Description: calculates total calories from the 2 arrays and outputs to screen //input params: count, the 2 arrays //output: total calories for each item and other info //return: none // void calcCalories(char items[][MAXCHAR], int otherData[][2], int count) { //tempCalories to calc total calories for each line int tempCalories = 0; for(int i = 0; i

*************************************************************************************

Make sure your data set meets the following requirements:

You must have at least one column of strings (like movie names, item names etc)

Keep your dataset simple - otherwise you will end up with too many parallel arrays that will make it very complicated to write code for.

You must use char arrays to store the strings and depending on the datatypes of the numbers, you can create single or 2-dimensional arrays.

Your data must be separated by semicolons or some delimiters other than space.

Check out the sample A06 to get an idea of what you need for your dataset. Which is the code above.

You must express your algorithm as pseudocode or a flowchart.

Write a function to open the text file created from your dataset and check to make sure it opens. If it does not open, the program exits.

Write a function to read from the text and do some data analysis. This could be comparing data such as finding the highest value or lowest value for a column.

Write a function to read from the text file and do some summation analysis. Find the sum or average of a column of data, or rows of data as shown below in the second example.

Then close the file and end the program.

You must use function prototypes and write your main() function at the top of your program, followed by the other function definitions.

Upload the text file you used with your program.

Run your program and compare it with the sample run below.

The below sample run is an example - your output will depend on your data set. You may not use this example!

image text in transcribed

The code must be in C++. Thank you. Please Include pseudocode or a flowchart. Thank you.

Data analysis is important in business to understand problems facing an organization, and to explore data in meaningful ways. Data in itself is merely facts and figures. Data analysis organizes, interprets, structures and presents the data into useful information that provides context for the data. https://www.kaggle.com/code/rtatman/fun-beginner-friendly-datasetsotebook Production has the highest share (81\%) Business has the lowest share (148) Data analysis is important in business to understand problems facing an organization, and to explore data in meaningful ways. Data in itself is merely facts and figures. Data analysis organizes, interprets, structures and presents the data into useful information that provides context for the data. https://www.kaggle.com/code/rtatman/fun-beginner-friendly-datasetsotebook Production has the highest share (81\%) Business has the lowest share (148)

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

Utopia The Social Audit

Authors: Travis E. Hughes

1st Edition

1505493374, 978-1505493375

More Books

Students also viewed these Accounting questions