0% found this document useful (0 votes)
5 views2 pages

Code

This C++ program calculates the amount of paint needed to paint a room by taking the room's dimensions as input. It considers the areas of a door, two windows, and a bookshelf that do not require painting. The program then computes the total wall area, subtracts the non-paint areas, and determines the gallons of paint required based on a specified coverage rate.

Uploaded by

mashihoharuto266
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Code

This C++ program calculates the amount of paint needed to paint a room by taking the room's dimensions as input. It considers the areas of a door, two windows, and a bookshelf that do not require painting. The program then computes the total wall area, subtracts the non-paint areas, and determines the gallons of paint required based on a specified coverage rate.

Uploaded by

mashihoharuto266
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;

int main()

// Constants for the area of the door, windows, and bookshelf

const double doorArea = 20.0; // Assuming door size is 20 square feet

const double windowArea = 15.0; // Assuming each window size is 15 square feet

const double bookshelfArea = 30.0; // Assuming bookshelf size is 30 square feet

// Constant for paint coverage

const double paintCoverage = 120.0; // Coverage in square feet per gallon

// Variables for the room dimensions

double length, width, height;

// Input room dimensions

cout << "Enter the length of the room (in feet): ";

cin >> length;

cout << "Enter the width of the room (in feet): ";

cin >> width;

cout << "Enter the height of the room (in feet): ";

cin >> height;

// Calculate the total surface area of the four walls

double totalWallArea = 2 * height * (length + width);


// Calculate the total area to subtract (door, windows, bookshelf)

double totalNonPaintArea = doorArea + 2 * windowArea + bookshelfArea;

// Calculate the area that needs to be painted

double paintArea = totalWallArea - totalNonPaintArea;

// Calculate the amount of paint needed

double paintNeeded = paintArea / paintCoverage;

// Output the amount of paint needed

cout << "The amount of paint needed to paint the room is: " << paintNeeded << " gallons";

You might also like