Вы находитесь на странице: 1из 2

Winter 2014, CISC101, Assignment 1

Assignment 1
Due by Moodle Submission before 7pm, Friday January 31 This assignment has three parts. You will write one program for each part and then submit three programs (as three files) to Moodle. Part A will give you practice writing expressions in Python. Part B will require you to construct nested conditional statements, and Part C has both a chained if structure along with an expression.

Part A - A Mortgage Calculator


Monthly mortgage payments can be calculated using the formula:

Where A is the monthly payment, P is the total amount borrowed (the principal), n is the number of months for repayment and i is the monthly interest rate. You can calculate the monthly interest rate by dividing the annual interest rate ("APR") by 12. For example, to borrow $30,000 (P) for a 10 year term (n = 120) with an APR interest rate of 6% (i = 0.06 / 12 = 0.005), A calculates to be $333.06 - the monthly payment. The total interest paid over 10 years (always depressing!) = 120 * $333.06 $30,000 = $9,967.38. For this assignment, assume that interest rates are fixed and the APR must lie between 1 and 10% inclusive. The term is always in years and must lie between 1 and 30 years inclusive. Payments are always monthly and the principal must lie between $1,000 and $500,000, inclusive. Write a program that prompts the user for the three required values and then calculates and displays the monthly payment and the total interest paid over the entire term.

Part B - Postal Rates


Here are the 2013 Canada Post postage rates for standard and non-standard or oversize envelopes to be delivered to the U.S.A. or Canada: Standard Letter Up to 30 g Over 30 g up to 50 g Other Letter Up to 100 g Over 100 g up to 200 g Over 200 g up to 300 g Over 300 g up to 400 g Over 400 g up to 500 g Canada $0.63 $1.10 Canada $1.34 $2.20 $3.05 $3.50 $3.75 $2.20 $3.80 $7.60 $1.10 $1.34 USA USA

The user must enter "USA" or "Canada" for the destination country - your program must treat any other entry as an error. The user can enter "y", when prompted, if the envelope is of a standard size - any other entry means "other". He can supply a number for the weight which must lie between 0 and 500 grams, unless the envelope is of standard size, where the weight must be less than or equal to 50 grams. If the user enters a weight over 50 grams for a standard envelope, change the envelope size to non-standard and continue on after telling the user that this is what you are doing. Your program for this part must obtain these three pieces of information and then output the postage rate.

Part C - Participation Grade


This program will prompt the user for their participation count (the number of postings) and then display the resulting grade as a percentage of their final mark. The count cannot be less than zero, but can have any positive value or zero. The conversion algorithm is described on the grading page and in a Moodle forum.

Additional Requirements and Notes


It is OK to put all your code in the main() function for all parts of this assignment. You can assume that the user will enter numbers when prompted for a number. It is OK for your program to crash if the user does not enter a number when he is supposed to. (However, if you don't like this - talk to your TA about how you
http://research.cs.queensu.ca/home/cisc101f/Winter2014/Assn1/Assignment1.html 1/2

Winter 2014, CISC101, Assignment 1

can detect non-numeric input and deal with it.) You must check to make sure that supplied parameters are in a legal range. If they are not, display a message to the user and exit the program by using the r e t u r nkeyword right after the error message. Display your dollar amounts to the nearest penny. For example, two thirds of a dollar would be displayed as "$0.67", not "$0.66" or "$0.7" or any amount with fractions of a cent (like "$0.667"). An even dollar would be displayed as "$1.00". You will not be closely graded on your documentation, but it would be appropriate to put a comment at the top of your program saying what the program does and who wrote it. A few short comments in the body of your program will help to explain what it is doing.

Grading
You will be marked out of 6 for part A, 6 for part B and 5 for part C for the proper and efficient operation of your code. 1 mark for each part will be allotted for the use of comments in your code, for a total mark out of 20.

Last modified: 01/11/2014 21:11:37

http://research.cs.queensu.ca/home/cisc101f/Winter2014/Assn1/Assignment1.html

2/2

Вам также может понравиться