/*************************************************/
// paint2.cpp
// R. A. Hillyard
// Last Modified:  09/10/2001
//
// Determine the number of gallons of paint needed for a given area.
// The user will enter the length and height in feet and inches
// This version allows the user to specify the number of areas
// to be used in calculating the total area
/*************************************************/

#include <iostream>

using namespace std;

const float SqFtPerGal = 300.0;

int main()
  {
  int numAreas;
  int count;
  float feet;
  float inches;
  float length;
  float height;
  float numGallons;
  float totalArea;
  		
  cout << "How many areas are there? ";
  cin >> numAreas;

  //initialization of variables used in loop
  totalArea = 0.0;    //total so far
  count = 1;          //initial value for counter

  while(numAreas >= count)
    {
    cout << "\nEnter the length in feet and inches for Area #" << count << ": ";
    cin >> feet >> inches;
    length = feet + inches/12.0;
	
    cout << "\nEnter the height in feet and inches for Area #" << count << ": ";
    cin >> feet >> inches;
    height = feet + inches/12.0;
	
    totalArea += length * height;    //compute new area and add to total
    count++;                         //increment count
    }//end for
		
  numGallons = totalArea/SqFtPerGal;  //calculate number of gallons
	
  cout << "\nFor " << count-1 << " Areas, ";
  cout << "You will need: " << numGallons << " gallons of paint to cover\n";
  cout << "the area of " << totalArea << " square feet" << endl;
	
  return 0;
  }

/***************Program Output***********************/  
How many areas are there? 3

Enter the length in feet and inches for Area #1: 10 6

Enter the height in feet and inches for Area #1: 35 8

Enter the length in feet and inches for Area #2: 15 0

Enter the height in feet and inches for Area #2: 10 0

Enter the length in feet and inches for Area #3: 8 9

Enter the height in feet and inches for Area #3: 8 9

For 3 Areas, You will need: 2.00354 gallons of paint to cover
the area of 601.063 square feet