5B PROGRAMSExcellence (6 points): Complete any three programs within 50 hours. All coding standards are demonstrated.
Advanced (5 points): Complete any three programs within the cycle. Proficient (4 points): Complete any two programs within the cycle. Basic (3 points): Complete any program within the cycle, and have a second attempted but non-functioning program submitted. Below Basic (2 points): Complete any program within the cycle. |
|
AvoidTheNoid
In each of ten villages resides a piece of an legendary puzzle that, if put together, will give you eternal life. No human has ever successfully avoided the Noid. Cyretrex, an aging war hero, wishes to go on a quest to become immortal.
The puzzle is guarded by the Noid--a mythical creature who can exist in two places at once. If you encounter the Noid on your quest to complete the puzzle, you will die.
Write a program that does the following:
EXAMPLE:
Please note: your personal style is encouraged. it does not have to look like this.
Cyretrex visits village 4.
Noid was in villages 1 and 9. Cyretrex captures puzzle piece 4.
DISPLAY: 0 X 1 X 2 X 3 X 4 V 5 X 6 X 7 X 8 X 9 X
Cyretrex visits village 8
Noid was in villages 2 and 8. Death Knell.
In each of ten villages resides a piece of an legendary puzzle that, if put together, will give you eternal life. No human has ever successfully avoided the Noid. Cyretrex, an aging war hero, wishes to go on a quest to become immortal.
The puzzle is guarded by the Noid--a mythical creature who can exist in two places at once. If you encounter the Noid on your quest to complete the puzzle, you will die.
Write a program that does the following:
- Places the Noid at two random (but different) villages numbered zero to nine.
- Lets Cyretrex select a village to approach.
- Tells us if the Noid was there or not. If he was, Cyretrex dies and the program is ends with a death knell (graphic of a bell ringing to note his death). If he wasn't, Cyretrex gets that piece of the puzzle.
- Shows a listing of which pieces of the puzzle Cyretrex has captured.
- Repeats back to step 1 above unless Cyretrex has captured the whole puzzle. If he has, the program shows a graphic of a palm branch to signify victory and eternal life.
EXAMPLE:
Please note: your personal style is encouraged. it does not have to look like this.
Cyretrex visits village 4.
Noid was in villages 1 and 9. Cyretrex captures puzzle piece 4.
DISPLAY: 0 X 1 X 2 X 3 X 4 V 5 X 6 X 7 X 8 X 9 X
Cyretrex visits village 8
Noid was in villages 2 and 8. Death Knell.
VowelCounter
Write a program that will take in a string (a single word, or multiple words separated by spaces) and count the proper vowels A, E, I, O, and U. The output of the program must not list vowels that were not seen. All inputs should be in all CAPS. For this program, Y will not be considered a vowel anywhere within the word.
This program must use switches to indicate when a vowel has been located in a word and thus must be printed at the end. The program must use tallies to count the number of vowels in the word. Use one switch and one tally per vowel. The switches and tallies may be individual longint variables or may exist within arrays--your choice.
TEST DATA:
INPUT: EDUCATION REGULATION
OUTPUT:
A = 2
E = 2
I = 2
O = 2
U = 2
INPUT: GET OUT OF HERE JOEY
OUTPUT:
E = 4
O = 3
U = 1
INPUT: FEEL THE RHYTHM!
OUTPUT:
E = 3
Write a program that will take in a string (a single word, or multiple words separated by spaces) and count the proper vowels A, E, I, O, and U. The output of the program must not list vowels that were not seen. All inputs should be in all CAPS. For this program, Y will not be considered a vowel anywhere within the word.
This program must use switches to indicate when a vowel has been located in a word and thus must be printed at the end. The program must use tallies to count the number of vowels in the word. Use one switch and one tally per vowel. The switches and tallies may be individual longint variables or may exist within arrays--your choice.
TEST DATA:
INPUT: EDUCATION REGULATION
OUTPUT:
A = 2
E = 2
I = 2
O = 2
U = 2
INPUT: GET OUT OF HERE JOEY
OUTPUT:
E = 4
O = 3
U = 1
INPUT: FEEL THE RHYTHM!
OUTPUT:
E = 3
SmartCycleBin
China has long been the world leader in accepting and processing recyclables from other countries. Over time, they found that much of what was shipped to them was contaminated. A wide variety of unusable material, from unrinsed yogurt containers to unrecyclable garden hoses to toxic waste, was showing up and creating an environmental crisis. The nation made a decision (effective 1/1/18) to stop accepting contaminated recyclables from other nations.
This has forced U.S. waste haulers to be more restrictive about what they accept, since they want to avoid the same problem (the one that they did not deal with for so long since they could "pass the trash" elsewhere). For example, Lancaster County will only accept the items shown in the image to the right: corrugated cardboard, clean plastic bottles (no lids), clean metal food and beverage containers (no lids), and clean glass jars and bottles (no lids). The hope is that these items can be more reliably recycled locally or can be shipped to China and not be graded as "contaminated".
The major factor in proper recycling is educated citizens who can understand what can and cannot be recycled. So, for this program, I want you to learn a little about plastics so you know what can and can't go in your bin.
Let's unpack the plastic issue. There are 7 types of plastics (as shown below), and while the arrows surrounding the numbers suggest they are recyclable, not all of the types are.
China has long been the world leader in accepting and processing recyclables from other countries. Over time, they found that much of what was shipped to them was contaminated. A wide variety of unusable material, from unrinsed yogurt containers to unrecyclable garden hoses to toxic waste, was showing up and creating an environmental crisis. The nation made a decision (effective 1/1/18) to stop accepting contaminated recyclables from other nations.
This has forced U.S. waste haulers to be more restrictive about what they accept, since they want to avoid the same problem (the one that they did not deal with for so long since they could "pass the trash" elsewhere). For example, Lancaster County will only accept the items shown in the image to the right: corrugated cardboard, clean plastic bottles (no lids), clean metal food and beverage containers (no lids), and clean glass jars and bottles (no lids). The hope is that these items can be more reliably recycled locally or can be shipped to China and not be graded as "contaminated".
The major factor in proper recycling is educated citizens who can understand what can and cannot be recycled. So, for this program, I want you to learn a little about plastics so you know what can and can't go in your bin.
Let's unpack the plastic issue. There are 7 types of plastics (as shown below), and while the arrows surrounding the numbers suggest they are recyclable, not all of the types are.
Generally speaking, polyethylenes are recyclable. #1 and #2 types, which are used for holding liquids, can be reformed into the same types of products and are always accepted curbside. #4, which is what grocery bags are made of, are recyclable as well--but almost never accepted at curbside pickup.
#3 (PVC) and #6 (polystyrene) are the major problem plastics because they don't decompose in landfills, may leach toxins, and can't be recycled easily or at all.
#5 (polypropylene), which the liner holding the cereal inside the box is made of, is sometimes accepted curbside and is recyclable.
#7 is a catch-all for all other plastics and, for that reason, can't be considered recyclable.
OK--program time!
------------------------------------------------------------------
The year is 2030, and environmental concerns have become significant after several political and natural events have put citizens on high alert. Waste management firms have successfully lobbied plastic manufacturers to put an invisible coating on their plastics that can be read by a scanner (much like a UPC or QR code). Each type of plastic has a unique invisible coating that represents the type by number (1 through 7).
You believe you have a successful business idea: the SmartCycle Bin. The plan is to sell these bins to trash companies to give to their customers. The customer places their each recyclable on top of the bin--which is actually a scanner bed. The bin then either accepts the item and drops it in or rejects the item and buzzes at the user (to indicate it should go in the regular trash). The trash company merely needs to program which types of plastics they wish to accept.
As the software programmer, you have this job to do:
- Begin the program in "Waste Hauler Programming Mode". Present the employee with the option of turning ON or OFF each of the seven types of plastic for acceptance.
- Then, the program goes into "Sensor Mode". In a loop, allow a number from 1-9 to be input and return a message of "accepted" or "rejected" based on how the waste company programmed the bin to operate for types 1-7. An 8 will be the option to empty the bin. A 9 will be the option to reset the machine, which returns this to Programming Mode. Any other value is "invalid".
- Once ten items have been accepted into the bin, force the user to enter an 8 to empty it, then return back to "Sensor Mode" again.
- Note: This program will loop infinitely and have no way to be quit besides pressing the red x (in real life, this would be unplugging the bin).
TEST DATA
Programming Mode:
1 ON
2 ON
3 OFF
4 OFF
5 ON
6 OFF
7 OFF
Sensor Mode:
2 ACCEPTED
3 REJECTED
2 ACCEPTED
8 BIN EMPTIED
1 ACCEPTED
1 ACCEPTED
1 ACCEPTED
1 ACCEPTED
1 ACCEPTED
4 REJECTED
7 REJECTED
1 ACCEPTED
1 ACCEPTED
2 ACCEPTED
2 ACCEPTED
5 ACCEPTED
User given message to empty bin
2 REJECTED (because bin was not emptied)
8 BIN EMPTIED
9 BACK TO PROGRAMMER MODE
Programming Mode:
1 ON
2 ON
3 OFF
4 ON
5 OFF
6 OFF
7 OFF
Sensor Mode:
1 ACCEPTED
4 ACCEPTED
5 REJECTED
2 ACCEPTED
1 ACCEPTED
3 REJECTED
6 REJECTED
5 REJECTED
4 ACCEPTED
4 ACCEPTED
2 ACCEPTED
5 REJECTED
1 ACCEPTED
1 ACCEPTED
1 ACCEPTED
User given message to empty bin
8 BIN EMPTIED
Press Red X to end program.
PerfectNumbers
A perfect number is a number that's proper factors sum to the number.
A proper factor is any factor of the number that is not the number itself.
We will define the "degree" of a perfect number as the number of factors in the sum.
The first Perfect Number is 6. The proper factors of 6 are 1, 2, and 3.
1 + 2 + 3 = 6.
The degree of the perfect number 6 is 3.
There are only four perfect numbers under 10000. Write a program that prints out those numbers and their degree. Your program must use a tally for the degree to earn credit.
Note: 1 is not a perfect number because 1 is not a proper factor of itself. Therefore, the sum of the proper factors of 1 is zero! All other positive integers have a proper factor of 1.
A perfect number is a number that's proper factors sum to the number.
A proper factor is any factor of the number that is not the number itself.
We will define the "degree" of a perfect number as the number of factors in the sum.
The first Perfect Number is 6. The proper factors of 6 are 1, 2, and 3.
1 + 2 + 3 = 6.
The degree of the perfect number 6 is 3.
There are only four perfect numbers under 10000. Write a program that prints out those numbers and their degree. Your program must use a tally for the degree to earn credit.
Note: 1 is not a perfect number because 1 is not a proper factor of itself. Therefore, the sum of the proper factors of 1 is zero! All other positive integers have a proper factor of 1.