have you ever wondered how many ditches
a pie we really need our two digits have
high enough how about 3 5 10 20 how many
digits up high you really need may
depend on what you're trying to do
imagine if NASA only used two digits of
pi to calculate the orbit the results
may not be so good it turns out nASA
uses 15 digits of pi in their
calculations resulting in the correct
orbits every time let's explore what
would happen if NASA used fewer digits
let's assume that the true circumference
of a circle can be calculated using pi
out to 15 decimal places the formula for
circumference is the diameter times pi
so this formula will represent the best
value of a circle circumference what we
want to know is how big of an air do we
get when we use fewer than 15 decimal
places in other words if we calculate
the orbit of the International Space
Station using only 3.1 how big is the
difference in both my house and
percentage from the circumference when
we use all 15 decimal places to do this
we're going to use the math class so
let's take a look at how we use the math
class in the editor okay so let's take a
look at how we use the math class we're
going to first take a look at getting pi
so we're going to print it out just so
we get a look at it so that's so system
dot out dot print line and we're just
gonna print it PI and we're gonna kind
of catenate it with hi and notice that
we use a capital M for math and we use
PI as capital P I when we run this we'll
see we get what pi is in the system in
PI Y and Java is actually sort out to 15
digits in a lot of our computer systems
that's how far we get out so now let's
say that take a look at how we can use
this to calculate a diameter of a circle
or circumference of a circle given a
diameter so let's just say that we have
int diameter equals 5
and we want to calculate our
circumference so we're going to say
double the circumference equals our
diameter times pi and so we're going to
use math dot pi okay and now let's print
that out and we can see what we have
okay and there you go we calculate our
circumference using math Chi now it's
your turn to explore this and compute an
exercise on your own