Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Three-dimensional array in C This project will require you to understand arrays. The goal of the project will be to use a 3 dimensional array

Three-dimensional array in C

This project will require you to understand arrays. The goal of the project will be to use a 3 dimensional array to store data that can be used to calculate totals in multi-dimensions. You will be required to write this code in the C language and work individually or in a group of up to 2 people on the project, but use the online forum for collaboration on anything related to the assignment for help (keep general questions on the forum, and contact me for class related issues, or if the forum is not helping).

You will have flexibility in what you want to hold in your 3 dimensional array, and you will need to create a header file that you will #include that contains the raw data. An example of an array would be as follows:

float cashIn [12][7][10];

This is an example of a data container that will hold float values as money. The dimensions in the array represent [12] months in a year, [7] days in a week, and [10] cash registers. NOTE: Keep the array dimension sizes small due to the fact that you will need (first dimension size) * (second dimension size) * (third dimension size) of data in your header file. Once you have your container defined, you will need at least 3 functions that use the data in the 3 dimensional array that will output a calculation from the function. One function will require an additional prompt for user input as in the example below for sumLane.

An example of the 3 functions could be:

float sumTotal(const float[][][]); //Sum all 3 dimensions

float sumWeekday(const float[][][]); //Sum 2nd dimension for values 1-5

float sumLane(const float[][][], int n); //Sum 3rd dimension for passed lane #

NOTE: but these types of function prototypes are only necessary for non-file scope defined arrays. If the variable is already at file scope, sending the variable through the function call should not be used.

In each of these functions you will need to use looping to iterate through a dimension (or multiple dimensions) as a set, and calculate a value based on an algorithm defined for the function. The algorithm chosen will require you to use nested for loops to understand how data passes through different blocks of code. Your algorithm will need to be clearly defined in your design document, as well as inputs and outputs per function. The calculations will need to use arithmetic in for loops to walk through the set and return a calculated value.

Your program can have either command line arguments passed to invoke the 3 functions, or you can utilize a menu system that will allow users to select the functions. An example of the menu for the above functions could look like:

MENU

------

Total for the entire year

Weekday totals for the year

Lane totals for the year (NOTE: will need another prompt for lane #)

Exit

Enter Selection : _____

A menu can be created easily with a while (true) loop that only exits if someone presses 4 and then the program will call exit().

while (1) {

printf(MENU );

printf(===== ;

.

printf(Enter selection : );

sel = getchar();

/* now use a switch statement to evaluate and if sel is not 1, 2, 3, 4, then print an error message and show menu again

*/

}

If you decide to not use a menu you will need to have a usage statement to let the user know how to use the command. An example would be if you allowed the user to enter:

$ calcCash

would print:

USAGE: calcCash [ showYear | showWeekday | showLane LaneNum ]

Requirements

Design document

Please create design doc in text format - not MS Word/etc

You are required to start with a design document that will define your program. The document will need to define at least the following elements:

Program description paragraph

Usage statement (menu or command line)

Data structure definition for 3 dimensional array

Each function defined with

Input type(s) (if any)

Output type

Algorithm description

Listing of files required and what type they are (.h header, .c c code, etc..)

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

2. What type of team would you recommend?

Answered: 1 week ago