-5

I need some help with a project I'm working on the side to help me in my physics and chemistry class.

This is the code that I have produced so far and it seems to give me an answer that are incorrect for all trials I have given it. All help is appreciated!

public double sinSinUnknown(double opp, double hyp)
{
    double sin = 0;
    sin = Math.asin((opp / hyp));
    return sin;
}

public double sinOppUnknown(double sin, double hyp)
{
    double opp = 0;
    opp = Math.sin(sin) * hyp;
    return opp;
}

public double sinHypUnknown(double sin, double opp)
{
    double hyp = 0;
    hyp = opp / Math.sin(sin);
    return hyp;
}

public double cosCosUnknown(double adj, double hyp)
{
    double cos = 0;
    cos = Math.acos((adj / hyp));
    return cos;
}

public double cosAdjUnknown(double cos, double hyp)
{
    double adj = 0;
    adj = hyp * Math.cos(cos);
    return adj;
}

public double cosHypUnknown(double cos, double adj)
{
    double hyp = 0;
    hyp = adj / Math.cos(cos);
    return hyp;
}

public double tanTanUnknown(double opp, double adj)
{
    double tan = 0;
    tan = Math.atan((opp / adj));
    return tan;
}

public double tanOppUnknown(double tan, double adj)
{
    double opp = 0;
    opp = adj * Math.tan(tan);
    return opp;
}

public double tanAdjUnknown(double tan, double opp)
{
    double adj = 0;
    adj = opp / Math.tan(tan);
    return adj;
}

}

Andy Turner
  • 122,430
  • 10
  • 138
  • 216

1 Answers1

0

The trigonometric functions in java.lang.Math require inputs in radians, rather than degrees. This can be done using the toRadians function.

You'll need to convert your answers back to degrees, using the toDegrees function.

public double sinSinUnknown(double opp, double hyp)
{
    double sin = 0;
    sin = Math.asin((Math.toRadians(opp) / Math.toRadians(hyp)));
    return Math.toDegrees(sin);
}
AJWGeek
  • 141
  • 7