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

Program in C l angauge only please Program: Painting a wall (C) (1) Prompt the u

ID: 3744649 • Letter: P

Question

Program in C langauge only please

Program: Painting a wall (C)

(1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (2 pts)


(2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall. Assume a gallon of paint covers 350 square feet. Store this value using a const double variable. (2 pts)


(3) Extend to also calculate and output the number of 1 gallon cans needed to paint the wall. Hint: Use a math function to round up to the nearest gallon. (2 pts)

what I have so far

#include <stdio.h>
#include <math.h> // Note: Needed for math functions in part (3)

int main(void) {
double wallHeight;
double wallWidth;
double wallArea;

printf("Enter wall height (feet): ");
scanf("%lf", &wallHeight);

printf("Enter wall width (feet): ");
scanf("%lf", &wallWidth);

// Calculate and output wall area
wallArea = wallHeight * wallWidth; // FIXME (1): Calculate the wall's area
scanf("%lf", &wallArea);
printf("Wall area: "); // FIXME (1): Finish the output statement

// FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

// FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

return 0;
}

Explanation / Answer

#include <stdio.h>

#include <math.h> // Note: Needed for math functions in part (3)

int main(void) {

double wallHeight;

double wallWidth;

double wallArea;

printf("Enter wall height (feet): ");

scanf("%lf", &wallHeight);

printf("Enter wall width (feet): ");

scanf("%lf", &wallWidth);

// Calculate and output wall area

wallArea = wallHeight * wallWidth; // FIXME (1): Calculate the wall's area

printf("Wall area: %f square feet ", wallArea); // FIXME (1): Finish the output statement

double paint = wallArea / 350.0;

printf("Paint needed: %f gallons ", paint);

// FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall

int cans = round(paint);

printf("Cans needed: %d can(s)", cans);

// FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer

return 0;

}

/*SAMPLE OUTPUT

Enter wall height (feet):

Enter wall width (feet):

Wall area: 180.000000 square feet

Paint needed: 0.514286 gallons

Cans needed: 1 can(s)

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote