darray - Fill in code to output month...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// This program demonstrates the use of dynamic arrays. // Joe Valinotti, Chaz Storm, Justin Carroll / #include <iostream> #include <iomanip> using namespace std; u int main() { float *monthSales; // a pointer that will be used to point to // an array holding monthly sales float total = 0; // total of all sales float average; // average of monthly sales int numOfSales; // number of sales to be processed int count; // loop counter cout << fixed << showpoint << setprecision(2); cout << "How many monthly sales will be processed? "; cin >> numOfSales; monthSales = new float(numOfSales); // Fill in the code to allocate memory for the array pointed to by monthSales. f cout << monthSales[count] << ":";
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Fill in code to output month number. << ":"; < // Fill in code to bring sales into an element of the array. //NEED THIS cout << "Enter the sales below"<<endl; for (count = 0; count < numOfSales; count++) { cout << "Sales for Month number "<<endl; cin >> monthSales[count]; total = total + monthSales[count]; for ( count = 0; count < numOfSales; count++) { total = total + monthSales[count]; } average = total / numOfSales; // Fill in code to find the average. cout << "Average Monthly sale is $" << average << endl; delete monthSales;// Fill in the code to deallocate the memory assigned to the array. system("PAUSE"); return 0; } }...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern