darray - Fill in code to output month...

Info iconThis 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] << ":";
Background 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

This note was uploaded on 11/13/2009 for the course CMSC 160 taught by Professor Webber during the Spring '09 term at Longwood.

Ask a homework question - tutors are online