Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite the program by grouping the code into functions by sectioning off separate logical processes. In particular, your program should include the following functions: 1.

Rewrite the program by grouping the code into functions by sectioning off separate logical processes. In particular, your program should include the following functions: 1. A bool function named menu().It takes no parameters. The purpose is to implement the main menu once and call other functions based on the users selection. The menu should return true untless the user selects Exit. After the menu is displayed, user makes a selection and appropriate functions are called, menu() should return a Boolean value. 2. A void named submenuPascal(). This function gathers the seed and size from the user and then calls pascal() function. 3. A void function named submenuFibonacci(). The purpose of the function is to gather the nth value from the user. It then calls the fibonacci() function. 4. A void function named pascal(). This function takes seed and size as parameters and calculates the values for the 2D array. 5. A void function named fibonacci(). This function takes int n as a parameter and performs the calculations for finding the nth Fibonacci number. 6. A void function named printPascale(). The function takes ostream& out, int matrix[][10], and int siz as parameters. The only purpose of this function is to print the Pascale triangle. Notice that the passed 2D array has a depth of 10. In order to pass the matrix, the matrix must be of fixed depth, rather than the dynamic depth (the height can stay dynamic) used in the original program. Fortunately, the range of depth is small to start with (5-10). Make the proper adjustments to the 2D array declaration and the code used to manipulate the 2D array to implement this change. 7. A void function named printFibonacci(). The function takes ostream& out, int n and string C as parameters. The only purpose of this function is to print the nth Fibonacci number in the format of the original program. 8. A function named addStrings()that returns a string, The parameters should be two strings. Implements the process of arithmetically adding two strings that hold large Fibonacci numbers and returns the result.

here is the code given:

#include  #include  #include  int main() { while(true) { int selection=0; std::cout<<"*******************MENU********************"<>selection; if(!std::cin) { std::cout<<"Invalid Input!"; std::cin.clear(); continue; } if(selection>3 || selection<1) { std::cout<<"Invalid Input!"; std::cin.clear(); continue; } break; } /// These could be made into a switch statement. How would that work? if(selection==1) { int seed=0; int siz=0; while(true) { std::cout<<"Enter an integer to start the triangle(1-999): "; std::cin>>seed; if(!std::cin) { std::cout<<"Invalid Input!"<>siz; if(!std::cin) { std::cout<<"Invalid Input!"<10||siz<5) { std::cout<<"Invalid Input!"<>n; if(!std::cin) { std::cout<<"Invalid Input!"<                        

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

Step: 3

blur-text-image

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

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago