

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Intermediate Java Programming; Subject: Computer Programming; University: Florida International University; Term: Fall 2007;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


DUE: Tuesday October 28, 2007 @ 5PM This assignment will deal mostly with Recursion. You can use the same menu implementation that was used in homework 2. Present the user with a menu that keeps displaying until ‘Q’ for quit is chosen. The menu should have 4 options one for each recursive method shown below. When the option is completed the menu is displayed again and awaits the user’s next choice.
Write methods for each of the following:
Write a recursive method that calculates Fibonacci numbers. Ask the user to enter an integer and then print out this many numbers. For example, if a user enters 10, then print out the first 10 Fibonacci numbers. The user should not enter a number less than 5 and greater than 20. Use the following link to learn how to calculate Fibonacci numbers: http://en.wikipedia.org/wiki/Fibonacci_number
Write a recursive method that reads an integer from the user; make sure the number is greater than 20. Divide the integer by 2 and print out the result, keep repeating the division by 2 until the remainder of the division is 1 or 0. For example if the user enters 10, you should print something similar to: 10/2 = 5 5/2 = 2 2/2 = 1 Finished dividing.
Write a recursive method the prints the first N even numbers starting with 0. Ask the user to enter an integer and then print out that many numbers. For example if a user enters 10, then print out the first 10 even numbers as shown below. Make sure the integer entered by the user is greater than 5.
0 2 4 6 8 10 12 14 16 18
Write a recursive method that adds the first N numbers starting with 0. Ask the user to enter an integer and then print out the sum of that many numbers. Show the intermediate sums at each step For example if a user enters 8, then print out each sum of the first 8 integers as shown below. Make sure the integer entered by the user is greater than 5.
0 1 2 3 6 9 15 24