It uses recursion I think? It is well laid out and easily readable. Basically it has a menu with 3 options, and the user picks one and it does the function, then returns them to the menu until they hit quit. Help me do getmenuchoice and getuserinput?
#include <iostream>
#include <cstdlib>
using namespace std;
// Prototypes
int fibonacci(int);
int factorial(int);
void printMenu();
int getMenuChoice();
int getUserInput();
/**
* This is the main function, where all of the functions will be called and the program
* will be controlled.
*/
int main(){
//YOUR CODE GOES HERE!
//Here your program will call functions in order to
//a. Print the menu
//b. Get the user's selection
//c. Based on that selection, do the proper function
//d. repeat from step a, unless they chose the 'Quit' option
return 0;
}
/**
* This function will calculate the 'num' fibonacci number in a recursive fashion.
* Valid values for 'num' are num >= 0
* @param num is the fibonacci index desired
* @return The value of fibonacci(num)
*/
int fibonacci(int num){
//YOUR CODE GOES HERE
if(n=0)return 0;
if(n=1)return 1;
if(n>1)return n>1;
else return n=n-1+n-2;
return n;
}
/**
* This function will calculate the factorial of num in a recursive fashion
* Valid values for 'num' are num >= 0
* @param num is the number for which we are calculating the factorial
* @return will be num!
*/
int factorial(int num){
//YOUR CODE GOES HERE
for (i = 0; i <= n; i++)
if (i == 0)
factorial = 1;
else
factorial = factorial * i;
}
/**
* This function will print out the entire menu for this program
*/
void printMenu(){
cout<<"*******************************"<<endl;
cout<<"Please choose an option:"<<endl;
cout<<"1. Factorial(n)"<<endl;
cout<<"2. Fibonacci(n)"<<endl;
cout<<"3. Quit"<<endl;
}
/**
* This function will get the user's menu choice.
* It will continue to ask the user for a value until a valid value (1-3) is given.
* @return a valid menu choice from the user.
*/
int getMenuChoice(){
}
/**
* This function will ask the user for 'n', which will eventually be used in the
* calculation of fibonacci or factorial.
* @return a value for 'n' to be used in calculating fibonacci or factorial.
*/
int getUserInput(){