# CS303E Project 3

#### Due Saturday, Feb 9, by 11pm

Write a program that helps the user determine whether to buy a wooden or ornamental iron fence based on its cost. Once the user has chosen, the program will also ask the user how much money (in US dollars) he or she plans to give the cashier, and then it will calculate the correct change.

Note: You may not use conditionals to calculate the change, and you may not use any programming construct that we have not covered in class at any point in this program.

Begin by prompting the user for the length of the fence to be built. Using that information, calculate the total cost of each type of fence based on these prices:

Wooden: \$16.27 per linear foot
Ornamental Iron: \$37.89 per linear foot

Print the total cost for each fence.

Next, prompt the user to choose either fence number 1 or fence number 2. The user will enter either the number 1 or the number 2.

After the user has chosen, tell the user that the fence company accepts only cash, and ask the user how much cash he or she is planning to give the fence builder and then calculate the user's change. Your change should involve the fewest possible number of coins, i.e. for \$.25, the change should consist of one quarter, not two dimes and one nickel. You may assume the user enters a numerical value higher than the cost.

Floating-point operations (arithmetic operations with values of type float) can result in round-off error. You need to make sure that you do not lose precision in the number of cents in your dollar amount.

Hint: Try multiplying the money amount by 100, then rounding to the nearest integer (with the round function) and casting this value to type int to get the number of cents.

For example:
cents = int(round(money*100))

Use tabs to line up the number of dollars, quarters, etc. in your output. (Reminder: you learned about a tab escape sequence!)

Your output should look like this for a fence 60 feet long:

`Please enter the length of the fence: 60The costs for the fences are:	1. \$976.20 for the wooden fence	2. \$2273.40 for the iron fenceWould you like fence 1 or fence 2? 1The fence company only accepts cash.How much money do you plan to give the fence builder? 991.54Your change, \$15.34, consists of:	15 dollars	1 quarters	0 dimes	1 nickels	4 pennies`

Test your program using at least 5 different test cases. Some recommended test cases:

1. 60 feet, wooden, 991.54
2. 45 feet, iron, 1705.32
3. 103 feet, wooden, 1677.64

`# File: --name of file--# Description: --a description of your program--# Assignment Number:## Name: --your name--# EID: --your eid--# Course Name: CS 303E## Unique Number: --your section number--## Date created:# Date last modified:## Slip days used this assignment:# Total slip days used:`

Use the turnin program to submit your Fence.py file. The file must be turned in by 11 pm on the due date. If you use slip days, please notify your grader when you turn in your file.

Did you remember to:

• do this assignment by yourself?
• name the file correctly?
• put your program in a main function?
• use tabs to line up the number of dollars, quarters, etc in the output?
• make use of meaningful variable names?