Write an application that allows users to work with the recursion algorithm to calculate values of the following. The recursion algorithm of each one will be defined in a static function of a data type class
n! | Factorial of an integer n where n provided from the keyboard |
an | a power n, where a and n are int numbers provided from the keyboard |
Sum(n) | Sum(n) = 1 + 2 + 3 + .. + n where n is an int provided from the keyboard |
Sum (m, n) | Sum(m, n) = m + (m+1), (m+2) + + n where m and n are int numbers provided from the keyboard |
Fn | Fibonacci sequence Fn = Fn-1 + F n-2; F0 = 0 and Fn1 = 1 |
GCD (n,m) | The greatest common divisor (GCD) of two integers m and n; m n where m, n are provided from the keyboard |
The application will allow users to select the task to do. After finishing one task, users can select to work with another task until they want to exit
1. n! ( Factorial of an integer n)
2. an (a power n)
3. Sum(n) = 1 + 2 + 3 + .. + n
4. Sum(m, n) = m + (m+1), (m+2) + + n
5. Fibonacci sequence Fn
6. GCD (The greatest common divisor of m and n)
The m and n are integer number that are read from the keyboard The output should be, for example:
Factorial of n = 5 is 120
2 to the power 3 is 8
Sum from 1 to 10 is: 55
Sum from 5 to 7 is 18
The Fibonacci at 10 is 55
Greatest Common Divisor (GCD) of 120 and 90 is 30
Provide the pseudo-code or flowchart of main
The data type class only contains static methods to calculate the values of the above formula
How to write a static method:
To create a static method, you just need to add the keyword static to the heading of the method. For example:
public static int factorial (int n) { .. }
You have to apply recursion algorithm write the code of all static methods
How to access static members of other class in main()
Create an application that allows users can work on the information of students with the following tasks:
1. Insert
2. Fetch
3. Encapsulation
4. Update
5. Delete
6. Show all
INSERT
FETCH
ENCAPSULATION
If both the phone numbers are the same then display the message "Binary Search Tree structure is not encapsulated" otherwise display the message Binary Search Tree structure is encapsulated =[
UPDATE
Display the message to ask users to enter the candidate id. Using the candidate id to read the node out the data structure as a candidate (or a candidate with experience). Asking for the new degree from the keyboard and change the degree of the candidate (or the candidate with experience) with the new degree to have a new node. Update the data structure with the new node with the same candidate id.
Display the message to see if update successfully or not
DELETE
SHOW ALL
Display all the candidate (or candidate with experience) are currently stored in the data structure