Академический Документы
Профессиональный Документы
Культура Документы
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.
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.
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.
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.
http://research.cs.queensu.ca/home/cisc101f/Winter2014/Assn1/Assignment1.html
2/2