Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 of 2 CS 150: Problem Solving and Programming I Lab#9 Description In this peogr

ID: 3730886 • Letter: 1

Question

1 of 2 CS 150: Problem Solving and Programming I Lab#9 Description In this peogram, you will complete eight functions in the template source code file. The peogram will imput the length and width of a rectangular room, calculate the area of the room, and determine the cost of painting the room. Notice that the headings for the functions are given. You need to fill in the function bodies and redo the returm statements so that the correet values are returned. There are some extra lines in the main function that should be removed after you have completed your solution. Each of these lines is commented with WRemove this le afr dehugging is complete. The only change that you should make te the main function is deletion of the indicated lines, Instuctions 1. The source file Lab9 Teplate.epp contains prototypes for eight functions. You should not change any of the code fromm the main function. 2. programmer info0 is void function displays the programmer information. 3. Promp' user to enter thc length using GetLength() function. 4 Prompt user to enter thc width using GerwidthO function. . Prompt user to enter the Gallon cost using GetGallonCost) fanction. 6. Calculate the area of the room using ComputeAreal) function 7.Use FindGallons) function to compute the number of gallons of paint needed. Global constant COVERAGE holds the number of square feet covered by one gallon. . . Calculate and returns the number of gallons Paint must be purchased by the gallon so if(Area % COVERAGE) yields a remainder, round up to the highest integer. se ComputeCost) function to calculale how much it would cost to buy all the Open With Print

Explanation / Answer

Let me know if you have any doubt.

#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>

using namespace std ;
// function prototypes
int GetLength();
int GetWidth();
double GetGallonCost();
int ComputeArea( int, int );
int FindGallons( int );
double ComputeCost( double, int );
void PrintResults( int, int, double );
// global constants
const int COVERAGE = 200; // 1 gallon of paint will cover 200 sq. ft.
int main()
{
// local variable declarations for main
int length; // length of the region to be covered
int width; // width of the region to be covered
int area; // area of the region to be covered; long int
// would be required to store large areas
int gallons; // number of gallons needed to cover the region
float gallon_cost; // price of a gallon of paint
float paint_cost; // the cost of the paint needed

// input data
length = GetLength();
width = GetWidth();
gallon_cost = GetGallonCost();

// process data
area = ComputeArea( length, width );
gallons = FindGallons( area ); // find number of gallons to
paint_cost = ComputeCost( gallon_cost, gallons ); // compute cost of paint
// print results
PrintResults( gallons, area, paint_cost );
return(0);
}

int GetLength()
{
int length;
cout << " Enter the length of the room(in feet; an integer): ";
cin >> length;
return length;
}

int GetWidth()
{
int width;
cout << " Enter the width of the room(in feet; an integer): ";
cin >> width;
return width;
}

double GetGallonCost()
{
int gallon_cost;
cout << " Enter the cost of a gallon of paint. ";
cin >> gallon_cost;
cout << fixed << showpoint << setprecision(2);
return gallon_cost;
}

int ComputeArea( int length, int width )
{
int area;
area = length * width;
return area;
}

int FindGallons( int paint_area )
{
float Area;
Area = (paint_area/COVERAGE);
Area = ceil(Area);
return Area;
}

double ComputeCost( double gallon_price, int num_gallons )
{
double paint_cost;
paint_cost = gallon_price * num_gallons;
return paint_cost;
}

void PrintResults( int gallons, int area, double paint_cost )
{
string results;
cout << " The area of your room is " << area << " square feet";
cout<<" One gallon of paint covers "<<COVERAGE<<" square feet";
cout << " you will need " << gallons << " gallons of paint.";
cout << " The total cost for paint is $" << paint_cost << "."<<endl;
}
// end of function declarations