Question: I am stuck. Can someone help me please? I need the answers for these. Thank you 1.Write a Java program that uses two recursivemethods to

I am stuck. Can someone help me please? I need the answers for these. Thank you

1.Write a Java program that uses two recursivemethods to do the following:a. The first method calculates and returns the value of 2n for n >=1. For example, if the user enters 5, then 25 = 32.b. The second method calculates and returns the sum of all the positive integers from 1 up to the number passed as an argument. For example, if 5 is passed as an argument, the method will return the sum of 1, 2, 3, 4, 5.c. In the main method, call these methods with user input. The user input should be validated.

2.Assume that there are N programming languages to learn, and you must learn X of them. How many possible combinations you can learn?For example, there are 3 languages: Java, Python, and C++, you must learn 2 of them. Then there are 3 combinations: [Java, Python], [Java, C++], and [Python, C++].Let function (n, x) to represent the number of combinations, given n languages to choose from and x languages to learn, the formula is shown below:function(n, x) = function(n-1, x) + function(n-1, x-1)

Write a program that includes a recursive method to compute function(n, x). Make sure that both n and x are greater than 0, and n is greater than or equal to x.

Sample run:

Enter the number of languages to choose from: 6

Enter the number of languages to learn: 4

Combinations: 15


Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the completed code for both questions written separately as two program... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Languages Questions!