Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ways to award colored medals to athletes: In a running race, a among a number of

ID: 3909575 • Letter: W

Question

ways to award colored medals to athletes: In a running race, a among a number of participants will be awarded colored medals. The lored number of people that are awarded medals is the same as the number of co medals. You are asked to write two met number of people to determine in le.g.- gold, silver, and bronze medals) among 10 participants. To design a program to solve this problem, you will use the Inl eerticipants For example, how many ways we can award a 1st, 2nd, and 3rd place prize and shown below. Since each medal is awarded to a different person, medal; both gold and there is no repetition (the same person can't have more than one the remaining medal choices get reduced each time. 1 x 2 x 3 x (n-1) x n silver) and ral n! medalPermutation (3,1)-3, medalPermutation (3,2)6, medalPermutation (4,3)-24 medalPermutation (10,2)-90, medalPermutation (10,3)-720 Complete the following program to generate the proper output shown below by defining (al ermutation function (medalPermutatio generating total number of permutation (choosing R out of N). You method/function definition must also include a proper function header (e.g., parameters and types). Enter a number of total participants:10 Enter a number of different awards: 3 Total combinations of choosing 3 out of 10 is 720 import java.util.Scanner; public class recursiveMedal f ublic static void main(String[] args) ( Scanner scan new Scanner(System.in); int participants, awards, totalkays; System.out.print ("Enter a number of total participants:") participants scan. next!nt(); System.out.print ("Enter a number of different awards: awards scan.nextInt(); = totalWaysmedalPermutation (participants,awards); System.out.printin("Total combinations of choosing awards + "out of"participants is totalWays);

Explanation / Answer

public static int factorial(int n)

{

int result;

if(n==0 || n==1)

return 1;

result = fact(n-1) * n;

return result;

}

public static int medalPermutation(int n, int r){

int numerator = factorial(n);

int denominator = factorial(n - r);

return numerator / denominator;

}

**Comment for any further queries.