Question

(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 wall height (feet): 12
Enter wall width (feet): 15
Wall area: 180 square feet
Paint needed: 0.514286 gallons


(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. Note that math and cmath are for our current purposes names for the same library. Look up the proper math library function on the web. Note that in the main lab, you will use a different technique to round. (Submit for 2 points, so 6 points total).

Enter wall height (feet): 12
Enter wall width (feet): 15
Wall area: 180 square feet
Paint needed: 0.514286 gallons
Cans needed: 1 can(s)

#include <iostream>
#include <cmath> // Note: Needed for math functions in part (3)
using namespace std;

int main() {
double wallHeight = 0.0;
double wallWidth = 0.0;
double wallArea = 0.0;

cout << "Enter wall height (feet): ";
cin >> wallHeight;
cout << endl;

wallWidth = 10.0; // FIXME (1): Prompt user to input wall's width

// Calculate and output wall area
wallArea = 0.0; // FIXME (1): Calculate the wall's area
cout << "Wall area: " << endl; // 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;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <cmath> // Note: Needed for math functions in part (3)
using namespace std;

int main() {
double wallHeight = 0.0;
double wallWidth = 0.0;
double wallArea = 0.0;

cout << "Enter wall height (feet): ";
cin >> wallHeight;
cout << endl;


cout << "Enter wall width (feet): ";
cin >> wallWidth;
cout << endl;
// Calculate and output wall area
wallArea = wallWidth*wallHeight; // FIXME (1): Calculate the wall's area
cout << "Wall area: "<<wallArea<< endl; // FIXME (1): Finish the output statement

// FIXME (2): Calculate and output the amount of paint in gallons needed to paint the wall
double paint = wallArea/350;//1 gallon = 250 sqfeet
cout<<"Paint needed:"<<paint<<" gallons"<<endl;
// FIXME (3): Calculate and output the number of 1 gallon cans needed to paint the wall, rounded up to nearest integer
//rounding to nearest gallon
int p = round(paint);
cout<<"Cans needed:"<<p<<" can(s)"<<endl;
return 0;
}

output:

Enter wall height (feet): 12

Enter wall width (feet): 15

Wall area: 180
Paint needed:0.514286 gallons
Cans needed:1 can(s)


Process exited normally.
Press any key to continue . . .


Add a comment
Know the answer?
Add Answer to:
(1) Prompt the user to input a wall's height and width. Calculate and output the wall's...
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
  • Specifications: • Prompt the user to input a wall's height and width. Calculate and output the...

    Specifications: • Prompt the user to input a wall's height and width. Calculate and output the wall's area. • 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. • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk,...

    In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylindrical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following: Prompts the user to input the dimensions (in feet)...

  • 5.15 PROGRAM: Functions - Upset Fowls (C++) (1) Correct the first FIXME by moving the intro...

    5.15 PROGRAM: Functions - Upset Fowls (C++) (1) Correct the first FIXME by moving the intro text to the function stub named PrintIntro and then calling the PrintIntro function in main. Development suggestion: Verify the program has the same behavior before continuing. (2) Correct the second FIXME by completing the function stub GetUsrInpt and then calling this function in main. Notice that the function GetUsrInpt will need to return two values: fowlAngle and fowlVel. (3) Correct the third FIXME by...

  • code in C++ Create a program that uses the pass by reference operator instead of the...

    code in C++ Create a program that uses the pass by reference operator instead of the return command. Your main program will need to: create empty variables call void function 1 with no input to display your name to the screen call function 2 to collect the square feet that a gallon of paint covers from user call function 2 to collect the square feet of wall that needs to be painted call function 3 to calculate the number of...

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