Question

Your assignment is to implement a computer program in C++ to implement the below application. According...

Your assignment is to implement a computer program in C++ to implement the below application.

According to Dummies.com the following algorithm determines the amount of paint you need to paint the walls of a four-sided room:

1. Add together the length of each wall. (For example, if each of the four walls are 14, 20, 14, 20 feet respectively then the total length is 14 + 20 + 14 + 20 = 68 feet)

2. Multiply the sum by the wall height, to find the total wall area. (In the example, if the wall height is 8 feet then the wall area is: 68 × 8 = 544 square feet)

3. Subtract 20 square feet for each door and 15 square feet for each window to find the actual amount of wall area you're painting. (So, if there are two doors and two windows, subtract 70 square feet: 544 – 70 = 474 square feet)

4. Divide this figure by the paint coverage (set at 350 square feet per gallon), and the result is the number of gallons to purchase. (Note: for the purposes of this assignment, the paint coverage is always set at 350 square feet per gallon.) 474 ÷ 350 = 1.4

5. Since paint is only sold in gallon increments, the final result is 2 gallons. The easiest way to round up, as required, is to use the C++ ceil() function. Don’t forget to #include <cmath> in your program header.

Sample Dialog:

Welcome to Robert's Paint Estimator

What is the length of wall 1: 14

What is the length of wall 2: 20

What is the length of wall 3: 14

What is the length of wall 4: 20

The total length of the wall is 68 feet

What is the height of the wall: 8

The total area of the wall is 544 square feet

How many doors are there: 2

How many windows are there: 2

Wall area to paint is 474 square feet

This will require 2 gallons of paint

Thank you for using Robert's Paint Estimator.

Design Considerations 1) Your program should follow exactly the example dialog above except that the name Robert should be replaced with your name. Please follow the formatting in the example exactly. In particular, be sure you output the required gallons rounded up to the next highest integer. 2) The text in red bold is that which is input by the user. The rest is output by your program. 3) Note: Of course, the results should be calculated by your program depending on what data the user inputs. In other words, your program needs to provide a general solution that will work for walls of all sizes, not just the example given above.

Homework Answers

Answer #1

Program:

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    string name;
    int wall1, wall2, wall3, wall4, total, height, area;
    int doors, windows, paintArea;
    float gallons;
    cout<<"Enter your name : ";
    cin >> name; // Input of your name to display
    
    cout << "Welcome to " << name << "'s Paint Estimator" << endl;
    // Input for length of walls
    cout<<"What is the length of wall 1: ";
    cin >> wall1;
    cout<<"What is the length of wall 2: ";
    cin >> wall2;
    cout<<"What is the length of wall 3: ";
    cin >> wall3;
    cout<<"What is the length of wall 4: ";
    cin >> wall4;
    total = wall1 + wall2 + wall3 + wall4;
    // Output total length of the wall
    cout << "The total length of the wall is " << total << " feet" << endl;
    
    cout<<"What is the height of wall: ";
    cin >> height; // Input height of the wall
    area = total * height;
    // Output total area of the wall
    cout << "The total area of the wall is " << area << " square feet" << endl;
    
    // Input for number of doors and windows
    cout<<"How many doors are there: ";
    cin >> doors;
    cout<<"How many windows are there: ";
    cin >> windows;
    paintArea = area - (doors * 20 + windows * 15); // Get painting area
    // Output paint area
    cout << "Wall area to paint is " << paintArea << " square feet" << endl;
    
    gallons =  (float)paintArea / 350; // Get number of gallons
    // Output the gallons using ceil() function
    cout << "This will require " << ceil(gallons) << " gallons of paint" << endl;
    
    cout << "Thank you for using " << name << "'s Paint Estimator" << endl;

    return 0;
}

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's length, width, and area Define an overloaded constructor and use it when creating the Rectangle object instead of using the setters. Change this program to calculate and display the rectangle's perimeter. Example: In feet, how wide is your house? 20 In feet, how long is your house? 25 The house is 20.00 feet wide. The house is 25.00 feet long. The house has 500.00...
Modify your Free Fall program below to plot the energy vs. time for a baseball dropped...
Modify your Free Fall program below to plot the energy vs. time for a baseball dropped from a height of 1000 feet until it hits the ground. Now add in the effects of air resistance into your program. This time, on the energy plot, you will plot four quantities: KE (Red line), PE (Green line), Energy lost due to air resistance (purple line), and total Energy (blue circles). Note, you must calculate the energy lost by using the definition of...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme values in the data set is the a. range b. median c. mode d. mean 2. If two events are independent, then a. they must be mutually exclusive b. the sum of their probabilities must be equal to one c. their intersection must be zero d. None of these alternatives is correct. any value between 0 to 1 3. Two events, A and B,...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...