Using the data file, “FactoryData”

300 450 500 210

510 600 750 400

627 100 420 430

530 621 730 530

200 050 058 200

100 082 920 290

Your program will:
1.      Read in that data file into a 2 dimensional array, 6 rows by 4 columns. Each row represents a Factory with 4 shifts. The integer value represents the number of units produced at each shift for that Factory.
2.      Allow the user to do several different tasks:
• Display the current Factories and each of their shifts’ production runs (e.g. each Factory 1 to 6 will each have 4 shifts).
• Calculate the Highest and Lowest production runs among all of the shifts (total of 24 different shifts, 6 different factories X 4 shifts each)
• Calculate the Average production run among all of the shifts (total of 24 different shifts, 6 different factories X 4 shifts each) PLUS the average production run PER each Factory among its own 4 shifts.
• Allow the user to manually change the production run value for a particular factory for one of its 4 shifts (e.g. Factory 3, Shift #4).
3.      Use functions to carry out each task. The main( ) is reduced to a switch that calls out one function
Since we have not yet reached memory pointers, we have a “minor tactical problem”:
• We cannot pass by reference (the memory location of the array)
• We cannot pass by value since a function can at most return one value. A function “cannot” see or access a variable or array declared within the main( ). Likewise the main( ) cannot see or access any variable or array declared in a function.
• We set the two dimensional array as a GLOBAL declaration making it available to the main plus any other functions in the file.

We know there is a maximum of 24 values (6 factories with 4 different shifts each). You may want to use a nested for loop since that would be the “easiest approach”.

The average for each individual factory would be an “interesting” calculation since we would have to know when to stop and when to start a factory within that nested for loop.

The first index location is always zero but humans are not use to seeing “Factory #0”. How would display it as “Factory #1” instead (and NO, let’s use all elements of the array and not ignore the “zero” row and “zero” columns).

If we change any existing value for a factory shift’s production run, we have to check for:
1. Valid Factory value (e.g. 1 to 6)
2. Valid Shift value (e.g. 1 to 4)
3. No negative integers for the production run (zero is legitimate as a value)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <string>
#include <fstream>
#include <iostream>

using namespace std;

int array [6][4];

void readFile(string fileName);
void displayShift();
int highest();
int lowest();
double average();
double averageOfFactory(int factory);
int changeProduct(int factory, int shift,int value);
void printMenu();

int main(int argc, char** argv) {
    int option = 0;
    int factory;
    int shift;
    int value;
    while (option != 5) {
       cin >> option;
       switch (option){
            case 1:...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats