| Due Time/Date: | Friday April 12th., 2002 at 10:00 p.m. UH-UNIX time. |
| What to do: | Write at least one class. The name of your application should be RecursiveMath. There is no need to append anything to the class name since it is not an applet. |
| How to turn in your homework? |
Send e-mail to ics211-homework@hawaii.edu. attaching the JAVA file. If you created any extra classes for this assignment, you must submit them as well. All these classes should be attached to your e-mail. The subject of your e-mail must be "Recursive Math". No zip files will be accepted. If any files arrived in zip format they will be discarded and you will get no credit for your work. Please make sure that your program compiles/runs properly in UH-UNIX. |
| Comments | Please comment all your classes and methods with a brief description of what each method does. Remember that nothing is obvious. Do not forget to add your your name to your program code. |
Your program should contain no "for" nor "while" loops, all the looping SHOULD be done using recursion.
Note that the specified menu should be recursive as well, and it should display the following options:
add (two numbers)
subtract (two numbers)
multiply (two numbers)
divide (two numbers)
power (two numbers)
factorial (one number)
summation (one number)
exit
Each one of these options should call a recursive method to perform the selected math operation. You may use the code from class.
Given the fact that the methods listed are only the methods' names, it is VERY important that you add explicit comments to your code. Note that neither the return values, neither the arguments are specified, this is for you to specify and comment.
|
Method |
Restrictions |
| add | Two numbers are given. Addition must be done with a recursive method that will increment by one every time. |
| subtract | Two numbers are given. Subtraction must be done with a recursive method that will decrement by one every time. The subtraction may result in a negative number. |
| multiply | Two numbers are given. Multiplication should be done by successive additions. This method does not need to call upon the add method. |
| divide | Two numbers are given. This method should implement integer division. Division should be done by successive subtractions. This method does not need to call upon the subtract method. Division can not result in a negative number. |
| power | The first number should be elevated to the power of the second number. |
| factorial | One number should be given and the factorial of it should be calculated. |
| summation | Given one number N the summation from 1 to N should be calculated |
Why do this assignment?
You will practice/learn:
Using recursion.
Practice your skills in command line interfaces and menus.
If you have any more questions please e-mail blanca@hawaii.edu