Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C++. Write o If user selects option 2, the user should then enter the number (n) to calculate the Fibonacci Series. Use the recursive

IN C++. Write

image text in transcribedimage text in transcribed
o If user selects option 2, the user should then enter the number (n) to calculate the Fibonacci Series. Use the recursive method and calculate the Fibonacci Series; as possible display the result from each recursive call until the final result (series) is obtained. a If user selects option 3, the user should then enter the number (n) to calculate the factorial. In this case, you will need to run the calculation using both methods, measure the time used to execute each method and display the resulting time (in seconds) for each method. You will not display the actual result. You may need to execute multiple times each calculation to obtain an execution time you can measure. a If user selects option 4, the user should then enter the number (n) to calculate the Fibonacci Series. In this case, you will need to run the calculation using both methods, measure the time used to execute each method and display the resulting time (in seconds) for each method. You will not display the actual series. You may need to execute multiple times each calculation to obtain an execution time you can measure. a You will need at ieast 5 functions, one for each of the following tasks: print header, factoriai recursive, factoriai - iterative, Fibonacci Series recursive and Fibonacci Series iterative. You may need more. You will also need to ensure that the output for each menu option displays the required information listed above. a For this assignment we will be using C++ 11, which allow us to support a long long (integer) data type and a more precise time measurement library. See the tutorial part of this assignment with instructions in how to configure Eclipse to use C++ 11. a Long long int uses 64 bits to storage an integer value so we can calculate factorial value for larger numbers. The range for unsigned long long int is: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 - As part of C++ 11 a new high precision clock library called chrono was included. Such library allows time measurement with precision as greater as microseconds. To measure the execution time of each implementation, you will use the ch rono library functions. In addition, you may need to execute multiple times each calculation to obtain an execution time you can measure. For instance, you may need to calculate the result 10 to 1000 times. See the tutorial part of this assignment for a sample code used to measure execution time of a function using the chrono library. Turn in as a single PDF file (IN THIS ORDER) 1. Screen |/O cut and paste into a txt file into eclipse. You will need the following six output: a. Option 1 select a number between 5 and 15 Option 2 select a number between 10 and 25 Option 3 select a number between 5 and 9 Option 3 select a number between 10 and 15 Option 4 select a number between 10 and 25 f. Option 4 select a number between 30 and 50 2. Header file. 3. Listing of main.cpp 4. Listing of your functions in a separate file from main.cpp. sharia Write a program that allows a user to compare the performance of a recursion based algorithm against to an iteration based (loop) algorithm. Your program will implement solution for two different problems using a recursive solution and an iterative solution for each problem. The rst problem is to calculate a factorial of a number (presented in class). You will need to include two algorithms, a recursive version and an iterative version. The factorial function for a number n (n!) is: n! = n*(n-1)*(n-2)*...*3*2*1 or n! = n* (n 1)! For n > 0 n! = 1 if n = 0 For example the factorial of n equal 9 is: 362,880 (= 9*8*7*6*5*4*3*2*1) The second problem is to calculate a Fibonacci Series. Fibonacci series is a series of numbers that are found by adding the two preceding (previous) numbers. The Fibonacci series can be determine by: fib(nl = fib(n-1)+fib(n-2) fib(O) = 0 fib(1) = 1 For example the Fibonacci Series for n equal 9 is: 0,1,1,2,3,5,8,13,21,34 Your program will have a menu with five options as shown below: MENU OPTIONS Calculate and Display Factorial of a Number Calculate and Display Fibonacci Series of a Number Compare Performance for Factorial Implementations Compare Performance for Fibonacci Series Implementations EXIT Enter an option (0 to exit): OideNH | Requirements 0 The user should be able to enter a choice in the menu. Check for input type mismatch. :- If user selects option 1, the user should then enter the number (n) to calculate the factorial. Use the recursive method and calculate the factorial; as possible display the result from each recursive call until the final result is obtained

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions