/*************************************************/ // paint4.cpp // R. A. Hillyard // Last Modified: 02/18/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 enter the number of areas to be input /*************************************************/ #include <iostream> using namespace std; const float sqFtPerGal = 350.0; int main( void ) { int count; float feet; float inches; float length; float height; float numGallons; float totalArea; //initialization phase totalArea = 0.0; //total so far cout << "How many areas? "; cin >> count; for(int i = 1; i <= count; i++) { cout << "\nEnter the length in feet and inches for Area #" << i << ": "; cin >> feet >> inches; length = feet + inches/12.0; cout << "\nEnter the height in feet and inches for Area #" << i << ": "; cin >> feet >> inches; height = feet + inches/12.0; totalArea += length * height; }//end for numGallons = totalArea/sqFtPerGal; cout << "\nFor " << count << " Areas, "; cout << "You will need: " << numGallons << " gallons of paint to cover\n"; cout << "the area of " << totalArea << " square feet" << endl; return 0; } /**************************Program Output**************************8 How many areas? 3 Enter the length in feet and inches for Area #1: 100 6 Enter the height in feet and inches for Area #1: 55 9.7 Enter the length in feet and inches for Area #2: 128 8 Enter the height in feet and inches for Area #2: 55 7.2 Enter the length in feet and inches for Area #3: 953 0 Enter the height in feet and inches for Area #3: 15 9.6 For 3 Areas, You will need: 79.4857 gallons of paint to cover the area of 27820 square feet */