Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static double askSine(int degrees)
- {
- int q1Degrees = scale(degrees);
- double radians = askRadians(q1Degrees);
- double sine = 10.0; //something went wrong if this appears
- if(degrees % 180 == 0)
- {
- sine = 0.0;
- }
- else if(degrees % 270 == 0)
- {
- sine = -1.0;
- }
- else if(degrees % 90 == 0)
- {
- sine = 1.0;
- }
- else
- {
- sine = 0.0
- for(int nthTerm = 1; nthTerm <= NUM_TERMS; nthTerm += 1)
- {
- sine += ((Math.pow(-1.0, (nthTerm - 1))) * ((Math.pow(radians, ((2 * nthTerm) - 1))) / (factorial((2 * nthTerm) - 1))));
- }
- }
- String quadrant = askQuadrant(degrees);
- if(quadrant == "Third" || quadrant == "fourth")
- {
- sine *= -1.0;
- }
- return sine;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement