Additional Challenges
Even Numbers in a List
- Create a new integer List with 5 values
- Set each of the List values to the first 5 even numbers
- Print them out to the Console
List of Names
- Create a new List of Strings
- Add these names to the list: Alice, Bob, Charles, Danielle, Edgar and Frannie
- Ask the user to add another name to the list
- Ask the user for a name to check if it in the list
- Use a foreach loop to check if it is
- Tell the user if the name is in the list or not
Create a collection of the first 100 Fibonacci numbers
Recall that the Fibonacci series is defined by the the nth number is the sum of the two previous:
f[n] = f[n-1] + f[n-2] => 0,1,1,2,3,5 ...
Use this information to find and store the first 100 fibonacci numbers.
- Start with
0
and1
as the first two numbers - Find the next by adding the first two together
- Ask the user for a number between
1
and100
- Print the fibonacci number of the number provided
Check if a string is a palindrome
A palindrome is defined as follows:
A group of characters that is the same forward as it is backwards. Palindromes normally do not take into account letter casing, spaces or punctuation.
Examples of some palindromes:
- Tacocat
- Hannah
- Kayak
- Never odd or even
- Rats live on no evil star
- (EXTRA CHALLENGE) A man, a plan, a canal - Panama!
Write a program that does the following:
- Asks the user to enter in a word or phrase
- Checks to see if this string is a palindrome
- If it is a palindrome, print out "Yes"
- Otherwise, print out "No"