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

Would using name tpoal work for inputting the name? Why or why no Would using na

ID: 3934853 • Letter: W

Question

Would using name tpoal work for inputting the name? Why or why no Would using name tpoal work for outputting the name? Why os why Try them both and see. LESSON 98 LAB 9.3 Dynamic Arrays Retrieve program darray.cpp from the Lab 9 folder. The code is as follows: This program demonstrates the use of dynamic arra PLACE YOUR NAME HERE include ciost ream> include using namespace stda int main a pointer used to point to an array float month Sales; holding monthly sales total of all sales float total 0; average of monthly sales float average number of sales to be processed int numof sales; loop counter int count cout fixed showpoint setprecision (2); cout How many monthly sales will be processed? cin numofsales; in the code to allocate memory for the array pointed to by Fill month sales

Explanation / Answer

// C++ code determien average monthly sale

#include <iostream>
#include <string.h>
#include <fstream>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
float *monthSales;
float total = 0;
float average;
int numOFSales;
int count;

cout << fixed << showpoint << setprecision(2);

cout << "How many months sales will be processed? ";
cin >> numOFSales;

monthSales = new float [numOFSales];

if (monthSales == NULL)
{
cout << "Error allocating memory ";
return 1;
}

cout << "Enter the sales below ";
for (count = 0; count < numOFSales; ++count)
{
cout << "Sales for month number " << (count+1) << ": ";
cin >> monthSales[count];
}

for (count = 0; count < numOFSales; ++count)
{
total = total + monthSales[count];
}

average = total/numOFSales;

cout << "Average Monthly sales is $" << average << endl;

delete[] monthSales;

return 0;
}

/*
output:

How many months sales will be processed? 3
Enter the sales below
Sales for month number 1: 401.25
Sales for month number 2: 352.89
Sales for month number 3: 375.05
Average Monthly sales is $376.40
*/

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