Java applet for the circumference and area of a circle

In the process of learning Java, you need to often take some small programs to practice. Today, let's take a look at a small program that uses Monte Carlo algorithm to calculate the PI and output the circumference and area of a circle with a specified radius.

The code is as follows:

Output:

Then you can enter the number of points on the console, find the approximate value of the PI, and then enter the radius of the circle you want to require to get the perimeter and area.

Example:

The Monte Carlo algorithm for calculating the approximate value of PI has been recorded in the author's previous articles.

The above is all about calculating the circumference and area of the circle in this paper. I hope this paper will be helpful to you.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>