4D PROGRAMSExcellence (5 points): Complete Fibonacci and YearEndBonus within 50 hours. All coding standards are demonstrated.
Proficient (4 points): Complete Fibonacci and have YearEndBonus completed by the end of Cycle 4. Basic (3 points): Complete Fibonacci by the end of Cycle 4. Below Basic (2 points): Complete Fibonacci by the end of Cycle 4. |
|
Fibonacci
Write a program that will calculate and store the first 25 Fibonacci numbers in an array. This should happen at the beginning of the program before inputs; the user will not see any calculation occurring. Ask the user to enter the Fibonacci number they wish to find, and print that number to the screen.
Mathematics: The Fibonacci sequence is a recursive sequence—meaning that previous numbers in the pattern affect future numbers.
Fibonacci numbers are noted as Fn, where n is the number in the sequence.
The initial number in the sequence: F0 = 0.
The next number in the sequence: F1 = 1.
These two numbers must be set to start the remainder of the pattern.
To find the next number (F2), add the previous two together (F1 + F0). Therefore, F2 = 1 + 0 = 1.
Then, F3 = F2 + F1 = 1 + 1 = 2.
Next, F4 = F3 + F2 = 2 + 1 = 3.
TEST DATA:
User wishes to see the 14th Fibonacci Number.
Output = 377
User wishes to see the 21st Fibonacci Number.
Output = 10946
Write a program that will calculate and store the first 25 Fibonacci numbers in an array. This should happen at the beginning of the program before inputs; the user will not see any calculation occurring. Ask the user to enter the Fibonacci number they wish to find, and print that number to the screen.
Mathematics: The Fibonacci sequence is a recursive sequence—meaning that previous numbers in the pattern affect future numbers.
Fibonacci numbers are noted as Fn, where n is the number in the sequence.
The initial number in the sequence: F0 = 0.
The next number in the sequence: F1 = 1.
These two numbers must be set to start the remainder of the pattern.
To find the next number (F2), add the previous two together (F1 + F0). Therefore, F2 = 1 + 0 = 1.
Then, F3 = F2 + F1 = 1 + 1 = 2.
Next, F4 = F3 + F2 = 2 + 1 = 3.
TEST DATA:
User wishes to see the 14th Fibonacci Number.
Output = 377
User wishes to see the 21st Fibonacci Number.
Output = 10946
YearEndBonus
The new CEO of a real estate firm wishes to implement a new incentive program for her agents to try to encourage growth in sales. Here's how it works.
At the end of the year, the employee will be awarded a bonus of up to $7200 (up to $600 per month over 12 months) dependent on their monthly sales growth.
Write a program that begins by taking in the sales for October, November, and December for the prior year (I suggest referring to these as months 10, 11, and 12). Then, take in the sales figures for months 1-12 of the current year. After each input, output the current total of the bonus. The final output should be the total bonus for the year.
TEST DATA:
Month 10, prior year = 4500
Month 11, prior year = 7200
Month 12, prior year = 6000
Month 1 = 6500 <--Meets incentive A, +100
Final Output: The year-end bonus is $2800.
The new CEO of a real estate firm wishes to implement a new incentive program for her agents to try to encourage growth in sales. Here's how it works.
At the end of the year, the employee will be awarded a bonus of up to $7200 (up to $600 per month over 12 months) dependent on their monthly sales growth.
- Incentive A: If the month's sales is greater than the prior month's sales, $100 is added to the bonus.
- Incentive B: If incentive A is met, and that month's sales is at least 5% greater than the sales total two months prior, $200 is added to the bonus.
- Incentive C: If incentive B is met (which means incentive A is too), and that month's sales is at least 10% greater than the sales three months prior, $300 is added to the bonus.
- NOTE: Employees can earn all three incentives each month! Therefore, meeting incentive C means the employee gets 100 + 200 + 300 = 600 since all three incentives are met.
Write a program that begins by taking in the sales for October, November, and December for the prior year (I suggest referring to these as months 10, 11, and 12). Then, take in the sales figures for months 1-12 of the current year. After each input, output the current total of the bonus. The final output should be the total bonus for the year.
TEST DATA:
Month 10, prior year = 4500
Month 11, prior year = 7200
Month 12, prior year = 6000
Month 1 = 6500 <--Meets incentive A, +100
- Output: Current Bonus = 100
- Output: Current Bonus = 400
- Output: Current Bonus = 1000
- Output: Current Bonus = 1000
- Output: Current Bonus = 1100
- Output: Current Bonus = 1700
- Output: Current Bonus = 1700
- Output: Current Bonus = 2300
- Output: Current Bonus = 2300
- Output: Current Bonus = 2400
- Output: Current Bonus = 2500
- Output: Current Bonus = 2800
Final Output: The year-end bonus is $2800.
ABC: Fibonacci2.0 (+2)
Update your Fibonacci Program to allow the user to set the period length n of the recursive sequence. The period of the traditional Fibonacci sequence is 2, since it sums the prior two numbers when calculating the sum. When increasing the period to length n, all values within the initial period from 1 to n should be equal to 1.
TEST DATA:
Period = 4
Sequence (not shown)= 1, 1, 1, 1, 4, 7, 13, 25, 49, 94, 181, 349, 673...
User wishes to see 14th value
Output: 1297
Update your Fibonacci Program to allow the user to set the period length n of the recursive sequence. The period of the traditional Fibonacci sequence is 2, since it sums the prior two numbers when calculating the sum. When increasing the period to length n, all values within the initial period from 1 to n should be equal to 1.
TEST DATA:
Period = 4
Sequence (not shown)= 1, 1, 1, 1, 4, 7, 13, 25, 49, 94, 181, 349, 673...
User wishes to see 14th value
Output: 1297