5A PROGRAMSExcellence (6 points): Complete PAElections, MakeUpYourMind, and TaxCalculator within 50 hours. All coding standards are demonstrated.
Advanced (5 points): Complete PAElections, MakeUpYourMind, and TaxCalculator by the end of the cycle. All coding standards are demonstrated. Proficient (4 points): Complete any two programs by the end of Cycle 5. Basic (3 points): Complete one program by the end of Cycle 5, and have another finished but not functioning. Below Basic (2 points): Complete one program by the end of Cycle 5. |
|
PAElections
Pennsylvania's most recent elections for four major governmental positions: Governor, U.S. Senator (A), U.S. Senator (B), and President took place in 2018, 2018, 2016, and 2016, respectively. Governors are re-elected every four years, as are U.S. Presidents. U.S. Senators are re-elected every six years. This program's goal is to take an input of a year between 1800 and infinity (all others are invalid) and output which positions will be up for re-election in those years. This program MUST use a nested if-then-else statement to be accepted.
Here's a table to show the six different possible siuations (labeled Patterns):
TEST DATA:
Input: 2040 Output: U.S. Senator (B), President
Input: 2182 Output: Governor
Input: 2080 Output: President
Input: 5389 Output: No Major Re-Elections
Input: 1776 Output: Invalid Entry
Pennsylvania's most recent elections for four major governmental positions: Governor, U.S. Senator (A), U.S. Senator (B), and President took place in 2018, 2018, 2016, and 2016, respectively. Governors are re-elected every four years, as are U.S. Presidents. U.S. Senators are re-elected every six years. This program's goal is to take an input of a year between 1800 and infinity (all others are invalid) and output which positions will be up for re-election in those years. This program MUST use a nested if-then-else statement to be accepted.
Here's a table to show the six different possible siuations (labeled Patterns):
TEST DATA:
Input: 2040 Output: U.S. Senator (B), President
Input: 2182 Output: Governor
Input: 2080 Output: President
Input: 5389 Output: No Major Re-Elections
Input: 1776 Output: Invalid Entry
TaxCalculator
Create a federal tax calculator for a single American that uses a single IF-THEN-ELSE statement. The examples shown early on in the Slides will help you, but those are in IF-THEN statements and need to be modified slightly.
The program must also be sensitive to bad data, such as negative dollar amounts. If a negative dollar amount is entered, the program should output the text “Invalid Entry” and end immediately.
EXPLAINING THE TABLE:
Americans are all taxed equally based on income. Everyone's first $9325 of earnings are taxed at a rate of 10% (one dime of each of those dollars goes to the federal government). Then, the dollars 9326 to 37950 earned are taxed at a rate of 15%. Dollars 37951-91900 are taxed at 25%, and so on based on the table.
Suppose that Sam earned 50000 in 2017. To calculate the tax, the table says to take "5226.25 plus 25% of the excess over $37950". That excess would be 50000 - 37950 = 12050. The tax would then be 5226.25 + 0.25*12050 = 8238.75.
Suppose that Jeff earned 100,000,000 in 2017. To calculate the tax, the table says to take "$121.505.25 plus 39.6% of the excess over $418400". That excess would be 100000000 - 418400 = 99581600. The tax would then be 121.505.25 plus 0.396*39434313.60 = 39555818.85.
TEST DATA: Besides the two above, here are some more.
Income = 90000 >>> Tax = 18238.75
Income = 150000 >>> Tax = 34981.75
Income = 10000 >>> Tax = 1033.75
Income = -20 >>> Invalid Entry
Create a federal tax calculator for a single American that uses a single IF-THEN-ELSE statement. The examples shown early on in the Slides will help you, but those are in IF-THEN statements and need to be modified slightly.
The program must also be sensitive to bad data, such as negative dollar amounts. If a negative dollar amount is entered, the program should output the text “Invalid Entry” and end immediately.
EXPLAINING THE TABLE:
Americans are all taxed equally based on income. Everyone's first $9325 of earnings are taxed at a rate of 10% (one dime of each of those dollars goes to the federal government). Then, the dollars 9326 to 37950 earned are taxed at a rate of 15%. Dollars 37951-91900 are taxed at 25%, and so on based on the table.
Suppose that Sam earned 50000 in 2017. To calculate the tax, the table says to take "5226.25 plus 25% of the excess over $37950". That excess would be 50000 - 37950 = 12050. The tax would then be 5226.25 + 0.25*12050 = 8238.75.
Suppose that Jeff earned 100,000,000 in 2017. To calculate the tax, the table says to take "$121.505.25 plus 39.6% of the excess over $418400". That excess would be 100000000 - 418400 = 99581600. The tax would then be 121.505.25 plus 0.396*39434313.60 = 39555818.85.
TEST DATA: Besides the two above, here are some more.
Income = 90000 >>> Tax = 18238.75
Income = 150000 >>> Tax = 34981.75
Income = 10000 >>> Tax = 1033.75
Income = -20 >>> Invalid Entry
MakeUpYourMind
This one is inspired by my home life. The users are a set of twin pre-schoolers who need to decide on dinner. Begin the program by asking for their names, then present them with dinner choices one at a time. Note: This is critical. Never give pre-schoolers a menu of several options to choose from. The options to be presented, in any order you like, are chicken nuggets, fish sticks, hummus & crackers, and soup. The child will respond with YES/Yes/Y/y/yes or NO/No/N/n/no. If all options are rejected, the kids get PB&J.
TEST DATA:
Remember that the order of foods presented is up to you. The two sets of test data show two different sequences of food choices.
Names = Mara, Hana
Mara, do you want hummus and crackers? No
Mara, do you want soup? YES
Hana, do you want hummus and crackers? Yes
OUTPUT = Honey, make Mara soup and Hana hummus and crackers. I'm going to mow the lawn.
Note: Your output doesn't need to be like that exactly, but must use names and foods paired properly.
Names = Jon, Chris
Jon, do you want chicken nuggets? Yes
Chris, do you want chicken nuggets? No
Chris, do you want hummus and crackers? NO
Chris, do you want fish sticks? n
Chris, do you want soup? N
OUTPUT = Honey, make Jon chicken nuggets and Chris PB&J. I'm going to the spa.
This one is inspired by my home life. The users are a set of twin pre-schoolers who need to decide on dinner. Begin the program by asking for their names, then present them with dinner choices one at a time. Note: This is critical. Never give pre-schoolers a menu of several options to choose from. The options to be presented, in any order you like, are chicken nuggets, fish sticks, hummus & crackers, and soup. The child will respond with YES/Yes/Y/y/yes or NO/No/N/n/no. If all options are rejected, the kids get PB&J.
TEST DATA:
Remember that the order of foods presented is up to you. The two sets of test data show two different sequences of food choices.
Names = Mara, Hana
Mara, do you want hummus and crackers? No
Mara, do you want soup? YES
Hana, do you want hummus and crackers? Yes
OUTPUT = Honey, make Mara soup and Hana hummus and crackers. I'm going to mow the lawn.
Note: Your output doesn't need to be like that exactly, but must use names and foods paired properly.
Names = Jon, Chris
Jon, do you want chicken nuggets? Yes
Chris, do you want chicken nuggets? No
Chris, do you want hummus and crackers? NO
Chris, do you want fish sticks? n
Chris, do you want soup? N
OUTPUT = Honey, make Jon chicken nuggets and Chris PB&J. I'm going to the spa.
ABC: PasswordCheck
Write a program that will ask the user to enter a password of up to 12 characters for an online account. Make the following suggestions to the user before they enter the password:
Any password will be accepted despite these suggestions, but the "strength" of the password will be suggested to the user.
You need to output this strength so the user knows how good of a password it is. In the event of an unacceptable password, make the user enter the password again. In the event of a troubled password, give the user the option of re-entering it again.
TEST DATA:
INPUT = password
OUTPUT = troubled, want to try again?
INPUT = yes
INPUT = Password
OUTPUT = acceptable
INPUT = code
OUTPUT = unacceptable, try again.
INPUT = Code
OUTPUT = troubled, want to try again?
INPUT = no
Write a program that will ask the user to enter a password of up to 12 characters for an online account. Make the following suggestions to the user before they enter the password:
- It should be at least 8 characters in length.
- It should contain at least one uppercase letter OR number.
Any password will be accepted despite these suggestions, but the "strength" of the password will be suggested to the user.
- A "unacceptable" password meets no requirements.
- A "troubled" password meets one requirement.
- A "acceptable" password meets two requirements.
You need to output this strength so the user knows how good of a password it is. In the event of an unacceptable password, make the user enter the password again. In the event of a troubled password, give the user the option of re-entering it again.
TEST DATA:
INPUT = password
OUTPUT = troubled, want to try again?
INPUT = yes
INPUT = Password
OUTPUT = acceptable
INPUT = code
OUTPUT = unacceptable, try again.
INPUT = Code
OUTPUT = troubled, want to try again?
INPUT = no