expand icon
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
Exercise 3
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.
Explanation
Verified
like image
like image

Refer code provided in Exercise 2-5 in t...

close menu
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
cross icon