
COMPUTER PROGRAMMING LAB
BONUS ASSIGNMENT(attempt any 20 questions)
1. A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage
charges an additional $0.50 per hour for each hour or part thereof in excess of three
hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car
parks for longer than 24 hours at a time. Write a program that calculates and prints the
parking charges for each of three customers who parked their cars in this garage
yesterday. You should enter the hours parked for each customer. Your program should
print the results in a neat tabular format and should calculate and print the total of
yesterday's receipts. The program should use the function calculateCharges to
determine the charge for each customer.
Your outputs should appear in the following format:
2. Write a function multiple that determines for a pair of integers whether the second is a
multiple of the first. The function should take two integer arguments and return true if
the second is a multiple of the first, false otherwise. Use this function in a program that
inputs a series of pairs of integers.
3. Write a program that inputs a series of integers and passes them one at a time to function
even, which uses the modulus operator to determine whether an integer is even. The
function should take an integer argument and return true if the integer is even and false
otherwise.
4. Write a function that displays at the left margin of the screen a solid square of asterisks
whose side is specified in integer parameter side. For example, if side is 4, the function
displays the following:
Car Hours Charge
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
TOTAL 29.5 14.50
****
****
****
****
5. Modify the function created in question no. 4 to form the square out of whatever
character is contained in character parameter fillCharacter. Thus, if side is 5 and
fillCharacter is #, then this function should print the following:
#####
#####
#####
#####
#####
6. Write a program that inputs three floating-point numbers and passes them to a function that
returns the smallest number.
7. (Perfect Numbers) An integer is said to be a perfect number if the sum of its factors,
including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect
number, because 6 = 1 + 2 + 3. Write a function perfect that determines whether