|
1 | | -# introductory-programming-assignments |
| 1 | +# Introductory Programming Assignments |
| 2 | +## Triangle Exercises |
| 3 | +### Easiest exercise ever |
| 4 | +Print one asterisk to the console. Example: |
| 5 | +``` |
| 6 | +* |
| 7 | +``` |
| 8 | + |
| 9 | +### Draw a horizontal line |
| 10 | +Given a number n, print n asterisks on one line. Example when n=8: |
| 11 | +``` |
| 12 | +******** |
| 13 | +``` |
| 14 | + |
| 15 | +### Draw a vertical line |
| 16 | +Given a number n, print n lines, each with one asterisk. Example when n=3: |
| 17 | +``` |
| 18 | +* |
| 19 | +* |
| 20 | +* |
| 21 | +``` |
| 22 | + |
| 23 | +### Draw a right triangle |
| 24 | +Given a number n, print n lines, each with one more asterisk than the last (i.e. one on the first line, two on the second,etc.). Example when n=3: |
| 25 | +``` |
| 26 | +* |
| 27 | +** |
| 28 | +*** |
| 29 | +``` |
| 30 | + |
| 31 | +## Diamond Exercises |
| 32 | +### Isosceles Triangle |
| 33 | +Given a number n, print a centered triangle. Example for n=3: |
| 34 | +``` |
| 35 | + * |
| 36 | + *** |
| 37 | +***** |
| 38 | +``` |
| 39 | + |
| 40 | +### Diamond |
| 41 | +Given a number n, print a centered diamond. Example for n=3: |
| 42 | +``` |
| 43 | + * |
| 44 | + *** |
| 45 | +***** |
| 46 | + *** |
| 47 | + * |
| 48 | +``` |
| 49 | + |
| 50 | +### Diamond with Name |
| 51 | +Given a number n, print a centered diamond with your name in place of the middle line. Example for n=3: |
| 52 | +``` |
| 53 | + * |
| 54 | + *** |
| 55 | +Bill |
| 56 | + *** |
| 57 | + * |
| 58 | +``` |
| 59 | + |
| 60 | +## FizzBuzz Exercise |
| 61 | +FizzBuzz is a simple number game where you count, but say "Fizz" and/or "Buzz" instead of numbers adhering to certain rules. |
| 62 | + |
| 63 | +Create a `FizzBuzz()` method that prints out the numbers 1 through 100. |
| 64 | +Instead of numbers divisible by three print "Fizz". |
| 65 | +Instead of numbers divisible by five print "Buzz". |
| 66 | +Instead of numbers divisible by three and five print "FizzBuzz". |
| 67 | + |
| 68 | +Sample Output: |
| 69 | +``` |
| 70 | +1 |
| 71 | +2 |
| 72 | +Fizz |
| 73 | +4 |
| 74 | +Buzz |
| 75 | +Fizz |
| 76 | +7 |
| 77 | +8 |
| 78 | +Fizz |
| 79 | +Buzz |
| 80 | +11 |
| 81 | +Fizz |
| 82 | +13 |
| 83 | +14 |
| 84 | +FizzBuzz |
| 85 | +``` |
| 86 | + |
| 87 | +## Prime Factors Exercise |
| 88 | +Write a method `generate(int n)` that given an integer N will return a list of integers such that the numbers are the factors of N and are arranged in increasing numerical order. |
| 89 | + |
| 90 | +For example, `generate(1)` should return an empty list and `generate(30)` should return the numbers: `2,3,5`. |
0 commit comments