math - Write a calculator for the identity sin² + cos² = 1 -
here's wrote:
public class math { public static void main (string[] args){ double degrees = double.parsedouble(args[0]); double s = math.sin(degrees); double c = math.cos(degrees); double x = s*s + c*s; system.out.println(x); } }
i want enter number args[0]
goes sin()
, cos()
. want add 2 variables making equal 1, because sin² + cos² = 1
. doing wrong?
edit: made changes code s*s + c*c
, i'm still getting same error.
i'm getting error:
2 errors found: file:... [line: 4] error: cannot find symbol symbol: method sin(double) location: class math file:... [line: 5] error: cannot find symbol symbol: method cos(double) location: class math
you not squaring each term calculating , printing sin(x) + cos(x)
. replace
double x = s + c;
with
double x = s*s + c*c;
and should right behaviour.
Comments
Post a Comment