Problem

Understanding Sequential StatementsIn this exercise, you use what you have learned about s...

Understanding Sequential Statements

In this exercise, you use what you have learned about sequential statements to read a scenario and then answer Questions. Suppose you have written a C++ program that calculates the amount of paint you need to cover the walls in your family room. Two walls are 9 feet high and 19.5 feet wide. The other two walls are 9 feet high and 20.0 feet wide. The salesperson at the home improvement store told you to buy 1 gallon of paint for every 150 square feet of wall you need to paint. Suppose you wrote the following code, but your program is not compiling. Take a few minutes to study this code, and then answer Questions.

// This program calculates the number of gallons of paint needed.#include using namespace std;int main(){double height1 = 9;double height2 = 9;int width1 = 19.5;double width2 = 20.0;double squareFeet;int numGallons;numGallons = squareFeet / 150;squareFeet = (width1 * height1 + width2 * height2) * 2;cout ≪ "Number of Gallons: " ≪ numGallons ≪ endl;return 0;}

You have two variables declared in this program to represent the height of your walls, height1 and height2. Do you need both of these variables? If not, how would you change the program? Be sure to identify all of the changes you would make.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 2.5
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