Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ Download the file.Comment the file completely. You should submit your

ID: 3593513 • Letter: U

Question

 Using C++  Download the file.Comment the file completely. You should submit your updated source file through the lab drop box in Blackboard. I need help with re-naming the variables and making the code look better. (Stick to giving the variables better names and to stick to the documentation style for c++) *************************************** CODE:  #include  #include   using namespace std; const int A_CONSTANT = 3;  void functionA(int a[], int aNumber); void functionB(int a[], int anotherNumber); void functionC(const int anArray[], int aNumber); void functionD(int& sum); int functionE(double number); void functionF(int n);  int main( ) {     int production[A_CONSTANT];     cout << "This program displays a graph showing " << "production for each factory in the company. ";     functionA(production, A_CONSTANT);     functionB(production, A_CONSTANT);     functionC(production, A_CONSTANT);     return 0; }  void functionA(int a[], int aNumber) {     for (int someNumber = 1;someNumber <= aNumber; someNumber++)     {         cout << endl << "Enter production data for plant number " << someNumber << endl;         functionD(a[someNumber - 1]);}}  void functionD(int& sum) {     cout << "Enter number of units produced by each department. " << "Append a negative number to the end of the list. ";     sum = 0; int next;     cin >> next;     while (next >= 0) {     sum = sum + next;     cin >> next;     } cout << "Total = " << sum << endl; }  void functionB(int a[], int anotherNumber) { for (int index = 0; index < anotherNumber; index++)     a[index] = functionE(a[index]/1000.0); }  int functionE(double number) { return static_cast(floor(number + 0.5)); }  void functionC(const int anArray[], int aNumber) {     cout << " Units produced in thousands of units: ";     for (int someNumber = 1; someNumber <= aNumber; someNumber++)     {         cout << "Factory #" << someNumber << " ";         functionF(anArray[someNumber - 1]);         cout << endl;     } } void functionF(int n) {     for (int count = 1; count <= n; count++) cout << "*"; } 

Explanation / Answer

commented and renamed the variable/function names with relevant names

Modified code.cpp

#include<iostream>
#include<cmath>

using namespace std;
const int FACTORIES = 3;

void companyDetails(int a[], int size);
void processData(int a[], int size);
void drawGraph(const int anArray[], int size);
void inputData(int& sum);
int fitData(double number); void horizontalBars(int n);

int main( )
{
int production[FACTORIES];
cout << "This program displays a graph showing " << "production for each factory in the company. ";
companyDetails(production, FACTORIES);
processData(production, FACTORIES);
drawGraph(production, FACTORIES);
return 0;
}

// Loop through all the factories and call input data for each factory
void companyDetails(int a[], int size)
{
for (int i = 1;i <= size; i++)
{
cout << endl << "Enter production data for plant number " << i << endl;
inputData(a[i - 1]);}}

//Takes input for a given factory from the user
void inputData(int& sum)
{
cout << "Enter number of units produced by each department. " << "Append a negative number to the end of the list. ";
sum = 0; int next;
cin >> next;
while (next >= 0) {
sum = sum + next;
cin >> next;
} cout << "Total = " << sum << endl;
}

//Process the data entered by the user by calling the fitData() function
void processData(int a[], int size)
{
for (int index = 0; index < size; index++)
a[index] = fitData(a[index]/1000.0);
}

//fit the data into integer form for easy plotting on graph
int fitData(double number) {
return static_cast<int>(floor(number + 0.5));
}

//This method draws the graph of the data enetered for the plants(FACTORIES)
void drawGraph(const int Factories[], int size)
{
cout << " Units produced in thousands of units: ";
for (int i = 1; i <= size; i++)
{
cout << "Factory #" << i << " ";
horizontalBars(Factories[i - 1]);
cout << endl;
}
}

// This function draws the horizontal bars in the graph with * symbol
void horizontalBars(int n) {
for (int count = 1; count <= n; count++) cout << "*";
}

PLEASE RATE ! !

Thanks !

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote