1.
Determine the number of cans of paint required to paint a room that is 12 feet wide and 15 feet long and 10 feet tall and each can of paint can cover 250 square feet of wall. The result should be stored in the variable
numCansPaint
.numCansPaint = 2 * 12 * 10 + 2 * 15 * 10 / 250 + 1;
- Incorrect. There are two walls that are 12 feet wide and 10 feet tall and 2 walls that are 15 feet wide and 10 feet tall, so multiply the sizes of the walls and add them together. Then divide by the amount of wall one can of paint will cover. Because all values are integers, it will be integer division. There will likely be some leftover so we need to add one more can of paint.
numCansPaint
is an integer because you can’t buy partial cans of paint. int numCansPaint = ((2 * 12 * 10) + (2 * 15 * 10)) / 250 + 1;
- Correct. There are two walls that are 12 feet wide and 10 feet tall and 2 walls that are 15 feet wide and 10 feet tall, so multiply the sizes of the walls and add them together. Then divide by the amount of wall one can of paint will cover. Because all values are integers, it will be integer division. There will likely be some leftover so we need to add one more can of paint.
numCansPaint
is an integer because you can’t buy partial cans of paint. int numCansPaint = (4 * 12 * 10 * 15) / 250 + 1;
- Incorrect. There are two walls that are 12 feet wide and 10 feet tall and 2 walls that are 15 feet wide and 10 feet tall, so multiply the sizes of the walls and add them together. Then divide by the amount of wall one can of paint will cover. Because all values are integers, it will be integer division. There will likely be some leftover so we need to add one more can of paint.
numCansPaint
is an integer because you can’t buy partial cans of paint. int numCansPaint = 4 * 12 * 10 * 15 / 250;
- Incorrect. There are two walls that are 12 feet wide and 10 feet tall and 2 walls that are 15 feet wide and 10 feet tall, so multiply the sizes of the walls and add them together. Then divide by the amount of wall one can of paint will cover. Because all values are integers, it will be integer division. There will likely be some leftover so we need to add one more can of paint.
numCansPaint
is an integer because you can’t buy partial cans of paint. int numCansPaint = 2 * 12 * 15 * 10 / 250 + 1;
- Incorrect. There are two walls that are 12 feet wide and 10 feet tall and 2 walls that are 15 feet wide and 10 feet tall, so multiply the sizes of the walls and add them together. Then divide by the amount of wall one can of paint will cover. Because all values are integers, it will be integer division. There will likely be some leftover so we need to add one more can of paint.
numCansPaint
is an integer because you can’t buy partial cans of paint.