4C PROGRAMSExcellence (6 points): Complete WhatsTheName, ParallelMultiply and Existence within 50 hours. All coding standards are demonstrated.
Advanced (5 points): Complete WhatsTheName, ParallelMultiply, and Existence within 50 hours. All coding standards are demonstrated. Proficient (4 points): Complete WhatsTheName and ParallelMultiply completed by the end of Cycles 3/4. Basic (3 points): Complete WhatsTheName by the end of Cycle 3, and have NoReps or Existence finished but not functioning. Below Basic (2 points): Complete WhatsTheName by the end of Cycle 3. |
|
WhatsTheName
Write a program that takes seven names as input, stores them in an array, and then allows the user to go back and have the computer recall names based on the numerical position of input for as long as the user likes.
TEST DATA:
INITIAL INPUT = Alan, Barry, Chloe, Doris, Eloise, Frank, Stu
User is asked which name he/she wishes to access
INPUT = 6
OUTPUT = Frank
User wishes to access another name
INPUT = 2
OUTPUT = Barry
User terminates the program
Write a program that takes seven names as input, stores them in an array, and then allows the user to go back and have the computer recall names based on the numerical position of input for as long as the user likes.
TEST DATA:
INITIAL INPUT = Alan, Barry, Chloe, Doris, Eloise, Frank, Stu
User is asked which name he/she wishes to access
INPUT = 6
OUTPUT = Frank
User wishes to access another name
INPUT = 2
OUTPUT = Barry
User terminates the program
ParallelMultiply
Create three parallel arrays of size 5. Prompt the user to enter five sets of two numbers for multiplication. Store the two numbers in matching compartments of the first two parallel arrays. Store their product in the matching component of the third array. Finally, output the five multiplication problems at the end in mathematical notation.
TEST DATA:
INPUTS
5, 2
6, 8
9, -2
10, 0
51, 24
OUTPUT:
Note: All five multiplication problems must print together at the end of the program, NOT immediately after each input.
5 * 2 = 10
6 * 8 = 48
9 * -2 = -18
10 * 0 = 0
51 * 24 = 1224
Create three parallel arrays of size 5. Prompt the user to enter five sets of two numbers for multiplication. Store the two numbers in matching compartments of the first two parallel arrays. Store their product in the matching component of the third array. Finally, output the five multiplication problems at the end in mathematical notation.
TEST DATA:
INPUTS
5, 2
6, 8
9, -2
10, 0
51, 24
OUTPUT:
Note: All five multiplication problems must print together at the end of the program, NOT immediately after each input.
5 * 2 = 10
6 * 8 = 48
9 * -2 = -18
10 * 0 = 0
51 * 24 = 1224
Existence
If one-hundred letters appeared at random, would your first name exist in that list? Write a program that simulates this question. Here are the main requirements.
If one-hundred letters appeared at random, would your first name exist in that list? Write a program that simulates this question. Here are the main requirements.
- Randomly generate one-hundred random letters (modules 1E and 3A are good reviews) and print the letter and its position number side by side with clear separators between numbers (module 2B might help with this).
- Ask for the user's name. Output each letter of the name, in order, with the position it first occurs at. See ZACH and AIDEN below for examples.
- If a letter is repeated, its position cannot be used twice. It needs to find the next instance of that letter. See EMMANUELLE below as an example. Hint: When a letter is printed, replace it in the array with a non-letter.
- If a letter is not in the list of one-hundred originally (see HARRIET) or a repeated letter does not have another instance (see ALESSANDRO), then output a message that says the name cannot be formed.
NoReps (ABC +2)
Set up an array to hold ten integers. This program needs to allow the user to input ten positive integers, but it must search the array after each input and ensure that that number had not already been added to the array. If it had been, the user must enter a new number. Such checks must continue until that compartment has a unique value. Output a list of the ten values at the end of the program.
This seemingly simple task is actually quite tricky, so some hints are given below.
Hints: You'll need a loop inside a loop, and each will need a unique counter variable. Don't use FOR TO DO for both loops, because one of them may need it's counter reset while the loop is running (and that can't be done inside a FOR TO DO loop).
TEST DATA:
INPUTS (and results):
1 (accepted)
2 (accepted)
2 (rejected), 5 (accepted)
3 (accepted)
1 (rejected), 2 (rejected), 4 (accepted)
6 (accepted)
7 (accepted)
8 (accepted)
9 (accepted)
1 (rejected), 5 (rejected), 3 (rejected), 6 (rejected), 10 (accepted)
OUTPUTS:
Your numbers were, in order: 1, 2, 5, 3, 4, 6, 7, 8, 9, 10
Set up an array to hold ten integers. This program needs to allow the user to input ten positive integers, but it must search the array after each input and ensure that that number had not already been added to the array. If it had been, the user must enter a new number. Such checks must continue until that compartment has a unique value. Output a list of the ten values at the end of the program.
This seemingly simple task is actually quite tricky, so some hints are given below.
Hints: You'll need a loop inside a loop, and each will need a unique counter variable. Don't use FOR TO DO for both loops, because one of them may need it's counter reset while the loop is running (and that can't be done inside a FOR TO DO loop).
TEST DATA:
INPUTS (and results):
1 (accepted)
2 (accepted)
2 (rejected), 5 (accepted)
3 (accepted)
1 (rejected), 2 (rejected), 4 (accepted)
6 (accepted)
7 (accepted)
8 (accepted)
9 (accepted)
1 (rejected), 5 (rejected), 3 (rejected), 6 (rejected), 10 (accepted)
OUTPUTS:
Your numbers were, in order: 1, 2, 5, 3, 4, 6, 7, 8, 9, 10
ABC : BowledOver (+2)
(problem concept derived from Cornell University's 2015 high school programming contest).
Calculating a player's score in bowling has become a lost art since the dawn of the computerized scoring system that is common at most alleys. Here are a couple bowling basics.
There are really just a few simple rules that dictate how the score is calculated (and how to get a perfect game of 300 by knocking down only 100 pins).
Still confused? Watch the video below.
Write a program that will take the inputs of the results of each throw and frame and output the score. You may have the user input the values in any way you choose, but they must enter X for a strike, / for a spare, and the individual digits for anything else. Also, an input of strike must not require a second input. Below is an example of a game and the scoring.
(problem concept derived from Cornell University's 2015 high school programming contest).
Calculating a player's score in bowling has become a lost art since the dawn of the computerized scoring system that is common at most alleys. Here are a couple bowling basics.
- In any game, a bowler will throw the ball at least 12 times and at most 21 times over 10 "frames" (a.k.a. turns).
- The first nine frames in a bowler's game will consist of two throws of the ball, unless the first throw results in a strike (symbol "X", knocking down all ten pins).
- The tenth frame is different.
- If the first throw is a strike, the player gets two more throws for a total of three throws.
- If the second throw is also a strike, the player still gets one more throw for a total of three.
- If the second throw is a spare (symbol "/", knocking down the remainder of the pins missed on the first throw), the player gets one more throw for a total of three throws.
- If the first throw is a strike, the player gets two more throws for a total of three throws.
There are really just a few simple rules that dictate how the score is calculated (and how to get a perfect game of 300 by knocking down only 100 pins).
- If a frame 1 ends "open" (not a strike or spare), then the number of pins knocked down contributes to the score.
- If a frame 1 ends in a spare, then the number of pins knocked down on the next throw (the first throw of the frame 2) is added to the ten from the spare of frame 1 to get the frame 1 total.
- If a frame 1 ends in a strike, then the number of pins knocked down on the next two throw (the first throw of the frame 2*) is added to ten from the strike of frame 1 to get the frame 1 total. \
- This scoring method continues throughout the game until frame 10. In frame 10, one additional throw is granted for a spare (to add to the existing spare) and two additional throws are added to a strike (to add to the existing strike).
Still confused? Watch the video below.
Write a program that will take the inputs of the results of each throw and frame and output the score. You may have the user input the values in any way you choose, but they must enter X for a strike, / for a spare, and the individual digits for anything else. Also, an input of strike must not require a second input. Below is an example of a game and the scoring.