//Compute how long it takes to Mow a Lawn on a Rectangular lot with // a Rectangular House, Given the Gardener Mows X Feet per Second // Output: Time in Hours, Minutes and Seconds // Input : Length and Width of the Entire Lot and the House #include #include // Find and Return the Area of a Rectangle to Nearest Foot Squared int area(int,int); //Args: Length, Width //Compute Time to Mow to the Nearest Second int timeToMow(int,int); // Args: Area, Feet Mowed Per Second // Output the Time to Mow in Hours, Minutes and Seconds void report(int); // Arg: Time to Mow in Seconds // Dimensions of Yard void getYardDimensions(int &,int &); // Dimensions of House void getHouseDimensions(int &,int &); // Can above two functions be merged into one? // Get speed of gardener void getMowRate(int &); // Main Routine void main() {int squareFeetPerSecond, yardLength,yardWidth, houseLength,houseWidth, areaToMow,seconds; getYardDimensions(yardLength,yardWidth); getHouseDimensions(houseLength,houseWidth); getMowRate(squareFeetPerSecond); areaToMow=area(yardLength,yardWidth)-area(houseLength,houseWidth); seconds=timeToMow(areaToMow,squareFeetPerSecond); report(seconds); } void getYardDimensions(int &length,int &width) {cout << "Enter length & width of yard>"; cout.flush(); cin >> length >> width; } void getHouseDimensions(int &length,int &width) {cout << "Enter length & width of house>"; cout.flush(); cin >> length >> width; } void getMowRate(int &sqFtPerSecond) {cout << "How Many Feet Per Second Does the Gardener Mow? >"; cout.flush(); cin >> sqFtPerSecond; } // Find the Area of a Rectangle int area(int Length,int Width) {return(Length*Width);} // Compute Time Required as Square Feet Divided by Square Feet Per Second int timeToMow(int Area,int Speed) {return(Area/Speed);} void report(int Seconds) {int Hours,Minutes; const int SecondsPerMinute=60,MinutesPerHour=60; // Compute Minutes and Remaining Seconds Minutes=Seconds/SecondsPerMinute; Seconds=Seconds%SecondsPerMinute; // Compute Hours and Remaining Minutes Hours=Minutes/MinutesPerHour; Minutes=Minutes%MinutesPerHour; cout << "Time required is " << Hours << " Hours, " << Minutes << " Minutes and " << Seconds << " Seconds\n"; }