Programming
Project I CIS 135
Points : 25
Due : At 11:59 PM
on the due date. No late submissions accepted.
PURPOSE: This
assignment employs the use of arithmetic operators (+ , ‑ , / , %) and
input and output routines.
PROGRAM:
A
local paint shop wants you to write a program that calculates the amount of
paint required (in gallons and quarts) when a customer specifies the area to be
covered in whole square feet. Your program should prompt for the area to be
covered, calculate the amount of paint required and give the answer in gallons
and quarts. Next, it will output the cost of the paint. Then, your program will
prompt the user for the amount tendered and will output the change, in $20
bills down to pennies.
The
paint must be enough to cover the entire space with excess of less than a
quart. The number of quarts must be an integer value in [0,3]. The price of the
paint per gallon is $25.83 and the price per quart is $6.79. 1
quart of paint covers exactly 50 square feet. Use constants for these three values.
How to
Calculate Paint Required: First, calculate the whole number of quarts of paint
required using division. This quantity of paint may not be sufficient to
completely cover the area. For example, if the area to be covered is 502 ft2,
502 divided by 50 is 10. BUT, 10 quarts will paint only 50*10 or 500 sq. ft.,
thus, leaving 2 ft2 unpainted. To calculate the correct number of
paint required, subtract one from the amount of square feet before calculating
the amount of paint required and then add 1 to the number of quarts
calculated. Once you have the total number of quarts required, you can convert
that to the number of gallons and the number of quarts required using division
and modulus. Remember that there are 4 quarts to a gallon.
To
calculate the change, input the amount tendered from the user. Compute the
change by subtracting the cost of the paint from the amount tendered. Then, use
division and modulus on the total change to find the number of notes/coins for
a particular denomination and the change remaining, respectively. For example,
change of $8.90 would start with zero twenty and ten dollar bills, leaving
still $8.90 to return. Next, using division, a $5 bill would be returned, and
an application of modulus would leave the remaining change at $3.90. Next,
three $1 bills, after which the remaining change is $0.90, etc; This can also
be done in reverse, using a factor of 5 to find pennies (value % 5) and
remaining 5 cent pieces, then 10 to find nickels and number of units of 10,
etc;
Example: A sample run
is in the box. Your output must be well labeled and accurate, although it is
not required to match the given output exactly. Note that to line up the number
of each item to return, the character \t, which is the tab character, can be
included in the cout string literal to line things up.
Documentation: Work submitted
is to be on a level appropriate for a Computer Science major. It is important
that you develop good habits in writing, formatting and documenting programs
from the start to avoid having to unlearn bad habits later.
What to
Submit:
Your
C++ file, named paint.cpp, using the turnin135 script.