Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In addition to the 'cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given in radians), can be

image text in transcribedimage text in transcribed

In addition to the 'cos' pre-defined function, which is found in the 'cmath' library, the cosine of an angle 'x' (given in radians), can be estimated using the following series (-1)k cos(x) (2k)! k=0 The series can be written as: -72k x 6 78 x2 r cos(x) = 1-1 + + 2! 4! 6! 8! Write a C++ program that reads a list of angles (in degrees) and the values of k (k represents the number of terms in .the above series) from an input file called (input.txt) The program should only accept angles between 0 and 180. When invalid angle is read from the file, an error message should be displayed (see the given sample output) The program should include the following user-defined functions Function 1 is called factorial, which is used to compute the factorial to be used in the above series 1 Function 2 is called series, which is used to compute the estimated cosine as given by the above series and 1 calculate the Error Marign (difference between cos(x) given by cmath and the estimated cos(x) based on the .given series) and send the program outputs to another file called (output.txt) as shown below .Hint: Use the same given data in the input file to check your code Do not use materials that we did not teach you such as struct, pointers, and 2-d arrays .Hint: Use the same given data in the input file to check your code Do not use materials that we did not teach you such as struct, pointers, and 2-d arrays input.txt 5 3 100 25 33 190 50 86 4 3 output.txt 100 25 33 190 50 86 COS Estimated Value Error Margin -0.173871 -0.173873 1.64296e-006 0.906284 0.906284 3.255e-008 0.83863 0.83863 2.99544e-007 ** angle is out of the range ** 0.642701 0.642693 8.28016e-006 0.0695623 0.0695781 1.57461e-005

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions

Question

What does it mean if a bond is convertible?

Answered: 1 week ago

Question

1. Explain what is meant by ethical behavior.

Answered: 1 week ago

Question

What roles have these individuals played in your life?

Answered: 1 week ago