Question: Write a program that displays the following list. Ask the user what action they want to take from the list below. Write the program
Write a program that displays the following list. Ask the user what action they want to take from the list below. Write the program using switch case and do-while. (1) Calculating the Fibonacci sequence (2) n!(n-1)!/(n+1)! calculation (3) Formula calculation Make your choice... After the process is done, ask the user if they want to continue. If he does not want to continue, ask him to enter -1. DETAIL; (1) Calculating Fibonacci sequence: Ask the user to enter a number. Print the fibonacci sequence according to the entered number. Use the recursion function. If the user enters 3 digits, the fibonacci sequence to be written on the screen will be 0 1 1 2. INDEX EXAMPLE 0 0 1 1 2 1 3 2 4 3 5 5 6 8 (2) n!(n-1)!/(n+1)! Calculation: Ask the user to enter the number n. Make the calculation according to the entered number and print it on the screen. (3) Formula Calculation: ask the user to enter the numbers a,b and c. Put the numbers in their places in the formula and print the result on the screen. You can use C## or python
Step by Step Solution
There are 3 Steps involved in it
Here is a program in Python that solves the problem as described Python program def fibonaccin if n 0 return 0 elif n 1 return 1 else return fibonaccin1 fibonaccin2 def calcnfactn1factdivn1factn return nn1n1 def calcformulaa b c return abcab choice 0 while choice 1 print1 Calculating the Fibonacci sequence print2 nn1n1 calculation print3 Formula calculation printMake your choice end choice intinput if choice 1 printEnter a number end n intinput printThe Fibonacci sequence is for i in rangen1 printfibonaccii end print elif choice 2 printEnter a number n end n intinput result calcnfactn1factdivn1factn printfThe result of nn1n1 for nn is result elif choice 3 printEnter numbers a b and c a b c mapint inputsplit result calcformulaa b c printfThe result of the formula for aa bb and cc is result else end printInvalid choice printThank you for using the program Explanation The program first defines three functions fibonacci ... View full answer
Get step-by-step solutions from verified subject matter experts
