Www2.cs.arizona.edu



Programming Project 2: DecisionsCollaboration: Solo! Work on these four programs by yourself.Due: Monday 19-Sep by 9:00 pm Turn in: Turn in all four files to the ISTA 130 D2L drop box named Project 2: SelectionGrading: 100 points. For specific criteria see the Grading Criteria section at the end of this fileThis programming project gives you a chance to implement some Input/Process/Output algorithms as Python programs where the process step involves decision statements if, else, and elif. At the beginning of each program, include comments with the information listed here where you have filled in the correct information for the [Appropriate parts]:# Developer: [Your name]## SL: [Your SL's name here] ## File: [programName.py]## Due: [Project Due Date and Time] ## Purpose: [A one-paragraph description of what the program does.] #The following example may be used as the beginning to the first program in a file name recordCertification.py (you need to change a few things):# Developer: [firstName lastName]## SL: [Your SL's name here]## File: recordCertification.py## Due Date: 9:00 pm Monday 19-Sep-11## Purpose: Determine the RIAA rating for a given number of records sold#**Program 1Music recording sales certification?is a system of certifying that a music recording has shipped or sold a certain number of copies, where the count varies by type (album,?single, music video, etc.) and by nation or territory. Almost all countries follow variations of the RIAA certification categories, for the count levels, which are named after precious materials:silver- moderate sales (half the gold count)gold - high salesplatinum - very high (often 2x-2.5x times gold count)diamond - extremely high (rare, 2x-10x platinum).Currently, the RIAA certification criteria for albums are:500,000 units: Gold album1,000,000 units: Platinum album2,000,000 units: Multi-Platinum album10,000,000 units: Diamond albumWrite a program in the file recordCertification.py that proceeses user input and computes which certification is appropriate. Print "No Certification" if there are fewer than 500,000 record sales.Album Sales? 49999No CertificationAlbum Sales? 1000000PlatinumAlbum Sales? 500000Gold albumAlbum Sales? 10000000Diamond**Program 2 A leap year is any positive integer that is evenly divisible by 4 except the last year of a century, which is a year that is evenly divisible by 100. In this case, the year must also be evenly divisible by 400. For example 2000 was a leap year, but 2100 will not be a leap year. Write a Python program in the file leapYear.py that processes user input to generate output like any of these sample dialogs always correctly stating if the given year is or is not a leap year.Year? 20002000 is a leap yearYear? 20112011 is not a leap year Year? 24002400 is a leap year Year? 20122012 is a leap year **Program 3 At a local school, the grading system computes the proper letter grade using the following plus/minus system:PercentageGrade 97.0 ? courseGrade < 100.0A+93.0 ? courseGrade < 97.0A90.0 ? courseGrade < 93.0A-87.0 ? courseGrade < 90.0B+83.0 ? courseGrade < 87.0B80.0 ? courseGrade < 83.0B-77.0 ? courseGrade < 80.0C+73.0 ? courseGrade < 77.0C70.0 ? courseGrade < 73.0C-67.0 ? courseGrade < 70.0D+63.0 ? courseGrade < 67.0D60.0 ? courseGrade < 63.0D- courseGrade < 60.0FComplete a Python program in the file letterGrade.py that processes user input to compute and print the correct letter grade like any of these sample dialogs below:Course Grade? 97.0Letter Grade: A+Course Grade? 82.9Letter Grade: B-Course Grade? 90Letter Grade: A-Course Grade? 75.0Letter Grade: CProblem 4 (Not a program, but a function with a return) There has been a lot of political debate about whether or not to extend tax cuts for the rich. This has a lot to do with the percentages of taxable income (income after deductions) that is owed to the IRS. Each person pays 10% of the first 10,000 of taxable income, 15% on another portion of the income, until the taxpayer has $372,950 in taxable income when the highest rate of 35% gets applied (ten years ago, the highest rate was 39.6%). The following tax table represents the amount of money owed for the year given the taxable income for the given year for a person filing with a single status:Write a Python function named incomeTax in a file named taxes.py. The incomeTax function takes the taxable income as an argument and always correctly returns the tax owed for the year. The return value must reflect the IRS rules for completing tax returns according to the table above. You may assume person is filing singly. The incomeTax function begins like this (make sure you name it incomeTax, it has one formal parameter and it returns a float rounded to two decimal places).# Developer: [firstName lastName]## SL: [Your SL's name here]## File: taxes.py## Due Date: 9:00 pm Monday 19-Sep-11## Purpose: Determine the amount of money a taxpayer owes the IRS for a year# of taxable income. his table is for those filing with Single status.## You can run this module to see the returned # results for as many function calls as you wish.#def incomeTax(taxableIncome): result = 0.0 if taxableIncome <= 8350.00: result = 0.10 * taxableIncome # more to do . . . . # more to do . . . . return round(result, 2) # end of function incomeTax(taxableIncome):# A few function callsprint(incomeTax(10.00)) # prints 1.0print(incomeTax(125.67)) # prints 12.57print(incomeTax(1234566)) # prints 0.0 until you add the code to handle thisOptional: The code above can be run as program. No user input is required for this problem. You could compute many test cases by hand, write many more function calls, and then compare your answer with program output. Or you could use Rick's tests, the same ones we will use to test your incomeTax function. One of the tests is provided here where assertions show a complete test of the first tax bracket of 0.00 through 8350.00. def testTaxFirstBracket(self): self.assertEqual(0.00, incomeTax(0)) self.assertEqual(0.10, incomeTax(1)) self.assertEqual(834.90, incomeTax(8349.00)) self.assertEqual(835.00, incomeTax(8350.00))If you want these tests plus a complete unit test for all brackets to ensure 100% correctness for the function incomeTax(taxableIncome):Get the file TaxesTest.py into the same folder as taxes.py Run TestTaxes.py as a module like your other programs (Run > Run Module F5)Look at the output to see which if any of Rick's test cases found a bug in your code.When you see the following output with no error messages, you will likely receive 30/30 or 100% for your function incomeTax(taxableIncome):......----------------------------------------------------------------------Ran 6 tests in 0.105sOK'''Grading Criteria 100pts total___ / 15 Program in recordCertification.py is correct. It always works for valid input___ / 20 Program in leapYear.py is correct. It always works for valid input (no bad input allowed)___ / 20 Program in letterGrade.py is correct. It always works for valid input (no bad input allowed)___ / 30 Function incomeTax in taxes.py is correct. Optional: You may use the same testsWe'll test with 20 assertEqual function calls worth 1.5 points each___/ 15 Style and Design___ / 5 You commented (documented) each program as requested ___/ 4 You used meaningful names for all identifiers in all four programs (subjective)___/ 6 Your dialogs from the first three programs is as requested or very close ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download