Java_Math

Java_Math - Mathematical Calculations and For Loops in Java...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1-10 Mathematical Calculations and For Loops in Java Topics 1. The Class Math 2. For Loops 1. The Class Math Many engineering mathematical functions (sin, cos, exp) are available as methods in the Math.java object. x function(x) These functions are methods of the class Math . They must be prefixed by the class name Math . double x, y; y = Math.function(x); Notice we assigned a new variable type double . The variables x and y are double precision floating points because functions like sin(x) and exp(x) are rarely integers. The word function here is not Java code. It just refers to any method in the Math class.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2-10 Functions you can use include the following – all of which must have the Math prefix, since each function is in fact a method in the Math class. Function Comment sqrt(x) x sin(x), cos(x) and tan(x) in radians! asin(x), acos(x) and atan(x) returns radians! random()
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

Java_Math - Mathematical Calculations and For Loops in Java...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online