Question: A. (20 points+2 potential bons points) Sin (The Sine Function) Write a CH+ program that uses a loop to compute and print the sin of
A. (20 points+2 potential bons points) Sin (The Sine Function) Write a CH+ program that uses a loop to compute and print the sin of an angle x to a tolerance specified by the user for following series: sin x x'/31 + xs/5' x'/?! + x,/91 where xisin radians. = x - - -... , An example run illustrating how your program should behave is specified on the following page -note, user input is in BOLD Welcone to the progeas to compute sinEx Enter tolerance tprecision)-exasple 0.00011 le-s The approxinate value of sinEx) for Ki 0.52359878 usings 4 termta) 0-49999999 Would you like to try again? t.Y. or y' to continue>| y Enter tolezance (preclaLon)-eximple o.0002 le-s The approximate value of sin(x) for : 1.57079632 using 8 tern[ Would you 1ike to try again? Y' or'' to contsnoe): Y 1.00000000 Ente: to1ezanee tpreeiaion)- example 0.0601: 0.G0001 The appeoxinate value of sint) to: x: -12.566 3706D usinq: 32 te ts) Would you like to try again? ['Y. or y' te eontinue); y 0.00000001 Enter x: 0 Enter tolerance tprecision-example 0.0001: 1m The appeoximate value of sih) fox : 0.00oDD00D using: 2 teemts) 0.obobo000 would you like to try again? K*t. oz .y. to eontinue) : n Constraints: Your program should obtain an input a value for x in degrees and convert it to radians. Define a global constant named PI in your program and set it to the value: 3.14159265 Your program must also input a valid tolcrance value from the user. A valid tolerance value is greater than 0 and less than I(eg 000001) If that is not the case, your program should report an error to the user, and re-prompt them to enter a value that is greater than zcro and less than I. Your program should continue in this manner until the user enters a number that is greater than0 and less than You should declare, define and use a function to get the input values (x in degrees, and tolerance) from the user. You can assume the value of x input by the user is valid (and convert it to radians but check the tolerance input by the user as described in constraint c above Print out the approximation of sin x with 8 digits to the right of the decimal point. Your solution should include a continuation loop that asks the user if they would like to continue after a value for sin x is successfully computed and printed out. You should test your program on a varicty of inputs in addition to the ones included above, sach as all of thc boundary conditions around key values of sin( such a 0, 1. 359. 29.30.31. and so forth. We will be doing so when we grade your peogram a. b. c. d. e. f. h. Comment your program according to the guidelines posted on the class Moodle site
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
