Combining the pieces, you have the following program:
#includeconst double pi = 3.14159; // Define the cylinder class: class cylinder { public: double radius, length; double volume ( ) {return pi * radius * radius * length;} }; // Define cylinder array: cylinder *oil_tank_pointers[100]; main ( ) { // Declare various variables: int limit, counter; double radius, length, sum = 0.0; // Read numbers and write them into pointer array: for (limit = 0; cin >> radius >> length; ++limit) { oil_tank_pointers[limit] = new cylinder; oil_tank_pointers[limit] -> radius = radius; oil_tank_pointers[limit] -> length = length; } // Compute volumes: for (counter = 0; counter < limit; ++counter) sum = sum + oil_tank_pointers[counter] -> volume ( ); // Display sum: cout << "The total volume in the " << limit << " storage tanks is " << sum << endl; } --- Data --- 4.7 40.0 3.5 35.5 3.5 45.0 --- Result --- The total volume in the 3 storage tanks is 5873.91