Question

Specifications: • Prompt the user to input a walls height and width. Calculate and output the walls area. • Extend to also
0 0
Add a comment Improve this question Transcribed image text
Answer #1

hello,

let us understand a little bit about number of cans of 1 gallon required to paint.

if paint needed = 0.514286 gallons, then you have to buy at least 1 gallon can to paint the wall.

if paint needed 0.4123 gallons, then also you have to buy at least 1 gallon paint to paint the wall.

So we have to round up the gallons needed to the next possible integer number.

as, for 0.514286, the round up value will be 1 and also , for 0.4123 , the round up value will be 1.

So using round function of "math.h" ,

the round(0.514286)=1, and since 1 gallon>0.514 gallon, so our need can be satisfied, but

the round(0.4123)=0, and 0 gallon<0.4123 gallon, so our need can not be satisfied using round function, so in situations like this where rounded value is less than amount of paint required, we will add 1 can extra,

So round(0.4123)=0 but 0<0.4123 so we will increment number of cans , and number of cans will be 1 , which will satisfy our need.

providing you the code for this problem:-

code starts here:-

#include <iostream>
#include<math.h>
using namespace std;

int main()
{
    double wall_height,wall_width,wall_area;
    double paint_required,cans_required;
    cout<<"Enter wall height (feet):";
    cin>>wall_height;
    cout<<"Enter wall width (feet):";
    cin>>wall_width;
    wall_area=wall_width*wall_height;
    cout<<"Wall area:"<<wall_area<<" square feet"<<endl;
    paint_required=wall_area/350;
    cout<<"Paint needed:"<<paint_required<<" gallons"<<endl;
    cans_required=round(wall_area/350);


    if(cans_required<paint_required)               //the condition to increment number of 1 gallon cans
        cans_required++;


    cout<<"Cans needed:"<<cans_required<<" can(s)";
}

code ends here:-

snapshot of the code:-

#include <iostream> #include<math.h> using namespace std; int main() double wall_height,wall_width,wall_area; double paint_re

output snapshot:-

Enter wall height (feet):12.0 Enter wall width (feet):15.0 Wall area:180 square feet Paint needed:0.514286 gallons Cans neede

i hope i was able to solve your problem to a greater extent, please feel free to comment your queries, Please consider my efforts and upvote my solution.

Thanku:)

Add a comment
Know the answer?
Add Answer to:
Specifications: • Prompt the user to input a wall's height and width. Calculate and output the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (1) Prompt the user to input a wall's height and width. Calculate and output the wall's...

    (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area. (Submit for 2 points). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet (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. (Submit for 2 points, so 4 points total). Enter...

  • in python please (1) Prompt the user to input a wall's height and width. Calculate and...

    in python please (1) Prompt the user to input a wall's height and width. Calculate and output the wall's area (integer). (Submit for 2 points). Enter wall height (feet): 12 Enter wall width (feet): 15 Wall area: 180 square feet (2) Extend to also calculate and output the amount of paint in gallons needed to paint the wall (floating point). Assume a gallon of paint covers 350 square feet. Store this value in a variable. Output the amount of paint...

  • A painting company has determined that for every 110 square feet of wall space, one gallon...

    A painting company has determined that for every 110 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $25.00 per hour for labor. Write a modular program that allows the user to enter the number of rooms that are to be painted (different colors) and the price of the paint per gallon. It should also ask for the square feet of wall space in each room. Rooms and gallons...

  • This exercise requires designing a program which solves the problem described in the problem statement below....

    This exercise requires designing a program which solves the problem described in the problem statement below. Provide comments as necessary in your pseudo-code and the Java program. Your solution must include these components: Flowchart Pseudo-code Hierarchy Chart Program Coded Program Output Problem Statement A painting company has determined that to paint 115 square feet of wall space, the task will require one gallon of paint and 8 hours of labor. The company charges $20.00 per hour for labor. Design a...

  • I am required to use the try - catch block to validate the input as the...

    I am required to use the try - catch block to validate the input as the test data uses a word "Thirty" and not numbers. The program needs to validate that input, throw an exception and then display the error message. If I don't use the try - catch method I end up with program crashing. My issue is that I can't get the try - catch portion to work. Can you please help? I have attached what I have...

  • CENGAGE MINDTAP gramming Exercise 3-8 PaintCalculator.java Instructions Assume that a gallon of paint covers about 350...

    CENGAGE MINDTAP gramming Exercise 3-8 PaintCalculator.java Instructions Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following: 1 import java.util.Scanner; 2 public class PaintCalculator { 3 public static void main(String args[]) { // Write your code here public static double computeArea double length, double...

  • A painting company has determined that for every 112 square feet of wall space, one gallon...

    A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. Write a program that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. Use a function (or multiple functions if you want) to calculate the following values - you also need to output...

  • C++, please make it as simple as possible. A Paint Company is hiring you to develop...

    C++, please make it as simple as possible. A Paint Company is hiring you to develop an application to estimate the costs for a job. They have determined that for every 120 square feet of wall area, one gallon of paint and eight hours of labor is required. The company charges US$ 18.00 per hour for labor. Write a modular program that allows the user to enter the number of rooms that are to be painted and the price of...

  • I need to write a paint job estimator program in python. I have most of it...

    I need to write a paint job estimator program in python. I have most of it down but i keep getting errors and I dont know how to fix it or what im doing worng specs: A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter...

  • Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a...

    Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a square. Sample Output (Your output should be similar to the text in the following box) Rectangle Calculator Rectangle or square? (r/s): r Height: 5 Width: 10 Perimeter: 30 Area: 50 Continue? (y/n): y Rectangle or square? (r/s): s Length: 5 Perimeter: 20 Area: 25 Continue? (y/n): n Thank you for using my app Specifications Use a Rectangle class that provides attributes to store the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT