English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

A method to approximate pi is...

pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 + ...

Write a java program that allows user to input the number of iterations for the approximation and compute the value of the approximation.

Thanks for help

2007-09-23 21:50:40 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

No. Do your own homework.

2007-09-23 22:01:39 · answer #1 · answered by oracle128au 7 · 0 1

Your loop will be incremented by 2 with an initial value of 1.
i=i+2;

The add or minus will flipflop so you need a flipflop flag.
Outside the loop set the flag to false
Inside the loop test the flag.
If it is true then you will add and make the flag false.
Else subtract and make the flag true.

You should know the rest.
If you do not then give up now. You don't stand a chance.

2007-09-24 05:18:22 · answer #2 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers