Make a program to calculate pi to the n'th decimal. Input the variable at runtime. Program In the language of you choice. (and none of the print"3.1415" crap.)
Name:
Anonymous2007-09-13 22:49 ID:/BBjeZZn
JAVA LOL
FINDING PI METHOD #1
import java.util.Random;
public class PiFinder
{
public double piSeries(int numberOfTerms)
{
boolean add = true;
double answer = 0.0;
double first = 1.0;
while (numberOfTerms > 0) {
if (add) {
answer += (1 / first);
first += 2;
add = false;
numberOfTerms--;
}
else {
answer -= (1 / first);
first += 2;
add = true;
numberOfTerms--;
}
}
return (answer * 4);
}
}