Computers and Technology

You will use conditionals, loops, and functions to implement a trigonometric functions calculator. THE PROBLEM
You must complete the provided Python program to calculate three trigonometric functions based on the user's input. The user can select the following trigonometric functions: 1. Sine, 2. Cosine, and 3. Tangent. The user will input option 4 to exit the program. If the user inputs a number different than 1, 2, 3, or 4, your program must print into the display the following message: Invalid option. Your program will keep asking the user for an option until the user choice is 4 (exit).
Trigonometric functions:
Sine: to calculate the sine of an angle (in radians), you must use the following Maclaurin series (Wikipedia):
sin(x) = βˆ‘[infinity]n=0(βˆ’1)nx2n+1(2n+1)!βˆ‘n=0 [infinity](βˆ’1)nx2n+1(2n+1)!
Where x is the value of the angle in radians.
Cosine: to calculate the cosine of an angle (in radians), you must use the following Maclaurin series (Wikipedia):
cos(x) = βˆ‘[infinity]n=0(βˆ’1)nx2n(2n)!βˆ‘n=0[inf inity](βˆ’1)nx2n(2n)!
Tangent: For the value of an angle different than 90 or 270 (in degrees), the tangent is:
tan(x) = sin(x)cos(x)sin(x)cos(x)
Where x is the value of the angle in radians.
User-defined Functions:
You must write the definition of the following functions:
factorial: this function receives as a parameter an integer value and returns the factorial of the received value. For a parameter equal to 5, the function returns 120 (5 * 4 * 3 * 2 * 1).
sin: this function receives two parameters (a float representing the value of the angle in radians and an integer value representing the number of terms of the Maclaurin series to be calculated). The function returns the value of the sine of the first parameter calculated with the first n terms of the Maclaurin series for the sine (where n is the second parameter received by the function).
cos: this function receives two parameters (a float representing the value of the angle in radians and an integer value representing the number of terms of the Maclaurin series to be calculated). The function returns the value of the cosine of the first parameter calculated with the first n terms of the Maclaurin series for the cosine (where n is the second parameter received by the function).
degTorad (provided): this function receives as a parameter an integer value representing an angle in degrees and returns the value of the received angle in radians.
printMenu (provided): this function does not receive parameters and does not return a value. The function prints the to STDOUT (display) the menu to be used by the user.
Main program:
The main program is provided in the template file. Please use the comments in the template file to complete your solution.
Input:
Your program takes as initial input one integer value representing the menu option. If the initial input value is a trigonometric function (1, 2, or 3), the program will request two additional inputs (an integer value representing an angle in degrees and the number of terms used in the Maclaurin series). The input statements are provided in the template file.
Output:
The print statements are provided in the template file (do not modify the output messages).
Note:
You can safely assume that the input will always be valid.
Example :
THE TRIGONOMETRIC CALCULATOR
1 - Calculate the sine of a value
2 - Calculate the cosine of a value
3 - Calculate the tangent of a value
4 - Exit
Enter your option: 1
Enter the value (in degrees): 45
Enter the number of terms: 10
The sine of 45 is 0.7071
THE TRIGONOMETRIC CALCULATOR
1 - Calculate the sine of a value
2 - Calculate the cosine of a value
3 - Calculate the tangent of a value
4 - Exit
Enter your option: 2
Enter the value (in degrees): 45
Enter the number of terms: 10
The cosine of 45 is 0.7071
THE TRIGONOMETRIC CALCULATOR
1 - Calculate the sine of a value
2 - Calculate the cosine of a value
3 - Calculate the tangent of a value
4 - Exit
Enter your option: 3
Enter the value (in degrees): 45
Enter the number of terms: 10
The tangent of 45 is 1.0000
THE TRIGONOMETRIC CALCULATOR
1 - Calculate the sine of a value
2 - Calculate the cosine of a value
3 - Calculate the tangent of a value
4 - Exit
Enter your option: 4

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:30, bstine6678
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
image
Computers and Technology, 22.06.2019 23:00, maxy7347go
Which factor is the most important when choosing a website host? whether customers will make secure transactions the number of email accounts provided the purpose of the website the quality of the host control panel
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, ahmedeldyame
Select the correct answer. which step can possibly increase the severity of an incident? a. separating sensitive data from non-sensitive data b. immediately spreading the news about the incident response plan c. installing new hard disks d. increasing access controls
Answers: 2
image
Computers and Technology, 24.06.2019 14:00, superstarsara5ouh83x
Fast answer i need for apex ! smartphones should be banned from the classroom in public schools so that students cannot cheat on test so easily? which is an example of a counter argument to the thesis above? a. the classroom is a place for learning not for making phone calls b. smartphones are useful learning tools in the modern classroom c. banning smartphones will not students pay attention to teachers any better d. banning smartphones would decreased incidents of theft
Answers: 2
Do you know the correct answer?
You will use conditionals, loops, and functions to implement a trigonometric functions calculator....

Questions in other subjects:

Konu
Mathematics, 11.01.2021 02:30