I'm quite good enough with Java syntax and just decided to put it to work by creating a code for sine based on an algorithm I created earlier. I know Math.sin helps you evaluate sine but I just for the fun, decided to go on an create my own source code. However, angles between 60° and 120° and also between 240° and 300° give wrong answers and I have no idea why. Could someone please help me find the error? I've tried everything to detect it but failed.
    import java.util.Scanner;
    public class Sine {
       public static void main(String[] args) {
          // This code solves sine according yo the general expansion of sine
          // sin x = x - x³/3! +x^5/5! - x^7/7! +...
          Scanner scanner = new Scanner(System.in);
          double answer = scanner.nextDouble();
          scanner.close();
          answer = simplify(answer);
          answer = converttoradian(answer);
          answer = continued(answer);
          System.out.println(answer);
       }
       // This Makes all the angles that are more than 360
       // To become less than 360 and Generates the simplified
       // Angles for obtuse and reflex angles
       static double simplify(double x) {
          if (x >= 360) {
             x = x - 360;
             return simplify(x);
          }
          else if (x <= -360) {
             x = x + 360;
             return simplify(x);
          }
          else if (x > 90 && x <= 270) {
             x = 180 - x;
             return x;
          }
          else if (x >= 270) {
             x = x - 360;
             return x;
          }
          else if (x <= -90 && x > -270) {
             x = -x - 180;
             return x;
          }
          else if (x <= -270) {
             x = x + 360;
             return x;
          }
          else {
             return x;
          }
       }
       // Simple enough and explains itself
       // Converts the angles to radian
       static double converttoradian(double d) {
          d *= Math.PI;
          d /= 180.0;
          return d;
       }
       // This Method about to open generates each term and adds them together
       // The number of terms solved in this case is 33
       static double continued(double d) {
          double answer = 0.0;
          int index = 1;
          double one = d;
          for (int i = 0; i < 33; i++) {
             double result = 0.0;
             for (int x = 1; x < index; x++) {
                d = d * one;
             }
             long here = factorial(index);
             result = d / here;
             if ((index - 1) % 4 == 0) {
                answer = answer + result;
                index = index + 2;
             }
             else {
                answer = answer - result;
                index = index + 2;
             }
          }
          return answer;
       }
       // Evaluates factorials
       static long factorial(int n) {
          long one = 1;
          long m = (long) n;
          if (m == 0 || m == 1) {
             one = 1;
             return one;
          }
          else {
             while (m > 1) {
                one *= m;
                m--;
             }
             return one;
          }
       }
    }
 
    