Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

anyone can help me with lab 6 C++ please 12:30 a kennesaw.view.usg.edu Lab 6- Functions: Tavlor Series Objectives Make use of various pass by value

anyone can help me with lab 6 C++ please image text in transcribed
image text in transcribed
12:30 a kennesaw.view.usg.edu Lab 6- Functions: Tavlor Series Objectives Make use of various "pass by value" functions to solve a single problem Apply programming to math (calculus) concepts The cosine of an angle can be computed from the following infinite series: Cosx-1-(x 2/2!)+(x 441)- Your task is to make a program that will calculate Cos x in the manner described above. To do this, you will need to make use of a number of functions and a menu system. Factorial This should take in a double n. This should return the factorial of n as a double. (You cannot return anything but a double do to the fact that no other data type can hold numbers large enough to support a factorial greater than 20) The formula for factorial is: Ex: 5!-5 43 21 Power Yes, there is already a power function defined in "cmath However, this time around you need to write your own version of this method. It should take in two numbers as parameters: a double b, representing the base, and an integer e, representing the power you wish to raise it to (exponent.) The method should return the answer as a double. These variable names are not required, just used as examples to help illustrate the reguirements. Eunction Write a function that takes in an angle x. Inside the function, compute the cosine of the angle using the first five terms of this series defined above. Print or return the value computed Hint: For loops will allow for a set number of calculations Function 12:30 kennesaw.view.usg.edu of this method. It should take in two numbers as parameters: a double b, representing the base, and an integer e, representing the power you wish to raise it to (exponent.) The method should return the answer as a double. These variable names help illustrate the requirements are not required, just used as examples to Function Write a function that takes in an angle x. Inside the function, compute the cosine of the angle using the first five terms of this series defined above. Print or return the value computed Hint: For loops will allow for a set number of calculations Function 2 Start by reusing the code from function. However, instead of calculating just the first five terms, this time you will continue to calculate terms while a given term remains greater than 0.0001 Make sure you print out the final result, and the number of terms used to calculate this result. Hint: Use a while loop for this one. Menu You should set up a menu that will allow the user to pick cither of the two functions above (methods for calculating the cos of x) In addition to having options for both of the above described ways of calculating cosine of x, you should include another case/option that will display the cosine of x according to the C++ default Library's function. The code to use the default library function is simply: cos(x) Run: When running the program, please run them with the following values in the following order: Option 1, x-0. Option 2, x-0. Option 3, x 0. Option I, x = 1, Option 2, x = 1. Option 3, x = 1 Option 1, x 2. Option 2, x 2. Option 3, x 2 Option 1, x-3. Option 2, x 3. Option 3, x 3. Option 1, x-4. Option 2, x-4. Option 3, x-4 Option 1, x = 5, Option 2, x = 5, Option 3, x = 5. Option I, x = 6, Option 2, x = 6. Option 3, x = 6. You will need to turn in your source code (cpp file) in addition to your output file in a zipped folder. Please submit the zipped folder to D2L See Lab 1's instruction sheet for documentation and further details on how to submit files

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Using Language That Works

Answered: 1 week ago

Question

4. Are my sources relevant?

Answered: 1 week ago