Review for Final

1)  Write a recursive method to print a string backwards.

2)  Write an iterative method to print a string backwards.

3)  Write a recursive method to compute the factorial of a number.

4)  Write an iterative method to compute the factorial of a number.

5)  Write a function that takes 2 arrays of 10 integers as arguments, and returns true if all of the elements in the first array match (in order) all of the elements of the second array.

6)  Write a function verify that takes an array of integers and the size of the array. The function returns true if the first element of the array is equal to the sum of the rest of the elements, false if not.

7)  Write a method(function) that reads integers from the input until the first non-zero integer is found. Return this number.

8)  Write a method (function) that takes an array of integers, the size of the array, and an integer skip as parameters. The method returns the sum of all numbers in the array, skipping the first skip elements.

9)  Write a program that reads an account balance (at the start of the month), the total value of deposits (for the month), the total value of withdrawals (for the month), and displays both the final balance and the net change to the balance.

10)  Write a program that reads integers count and marker from the input. It then reads count integers. Of these integers, the program prints the first integer after any time marker appears. For example, input of "8 0 0 2 3 0 0 -3 0 10" should result in output of "2 0 -3 10". Notice that in this input, count = 8 and marker = 0 and there are 8 integers following the input of 8 and 0.

11)  Write a function shuffle that takes an array of 20 integers and then shuffles the integers using the following algorithm: For each element X of the array, generate a random number N between 0 and 19, inclusive. Swap X with the element that corresponds to N.

12)  Write a program that reads integers with values guaranteed to be in the range 1-5 from the keyboard and prints the mode, that is, the integer which appears the most frequently and how often it appears. You should also be able to write this as a function. (Similarly, write a program and/or function which does the same for an array of 100 integers in the range 1-5).

13) Implement the following Money class. When you finish your implementation, write a driver to test it.

public class Money
{
public final char SYMBOL = '$';
private long dollars;
private long cents;
}

14). Define a extMoney class to extend the above money class to include a field that says whether the money is real money or play money.

public class ExtMoney extends Money
{
private String kindOfMoney;

}

15) What are the obligations of a class that implements a specific interface? Briefly explain

16) What is catch or declare rule?

1