Answered You can hire a professional tutor to get the answer.

QUESTION

Directions YourNameAssign05.cpp This program will do the same that Assignment 4 did, except this time the number of stores will be a number n from 1...

Directions

YourNameAssign05.cpp

This program will do the same that Assignment 4 did, except this time the number of stores will be a number n from 1 to 10 (inclusively). The main method should obtain this number n from the user. The program will not proceed until a proper number n is given. Once the number n is obtained, the main method will initialize dynamic array of n structures. The structures will be defined in the program to contain 5 numeric attributes for each store. These will be integer and double number. We will not use string since they may complicate your programs. 

After declaration, creation of initialization of this dynamic array, the main method will call the following functions:

1. printable to print all data in the arrays properly labeled and aligned.

2. sortData to sort array.

3. printable again to print all sorted data.

These functions above are described as follows:

printTable function

This function will receive the dynamic array defined in main and print a table containing the information contained within the array. Every row in the table will contain the information for the same store (n rows) and every column will contain the information of the same attribute for all stores (5 columns with number attributes). Print appropriate headers for the table and each column. Print an index number (from 1 to n+1) in front of each row. All columns should be aligned.

sortData function

This function will receive the dynamic array defined in main and sort it based on one of your integer attributes from lower to higher value. Remember that this time you are only sorting one array, but is an array of structures with multiple data per store.

Do not forget to add comments to the code. The .cpp file must have a head of comments indicating the name of the file, the name of the author, and a brief description of the program. Each function must have also have a head of comments indicating the name of the function and a brief description of what it does. All variable names must also be documented.

Assignment 4

#include <iostream>

#include <string>

using namespace std;

// prints the given arrays in tabular form along with the indices

// First, the header is printed then each of the parallel

// arrays elements is printed on the same row.

// Each column contains the data of the same array

void printTable(string[], float[], float[], int[], int[], int[]);

// Sorts all the parallel arrays based on the number of brancehes

// each of the arrays values are transformed to reflect the

// store with the minimum branches at the first location

void sortData(string[], float[], float[], int[], int[], int[]);

int main()

{

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question