集册 Java实例教程 计算圆周长

计算圆周长

欢马劈雪     最近更新时间:2020-01-02 10:19:05

509
圆的周长是2 * pi * r

 

import java.io.BufferedReader;

import java.io.IOException;/*来自 N o w J a v a . c o m - 时代Java*/

import java.io.InputStreamReader;

 

public class Main {

 

        public static void main(String[] args) {

               

                int radius = 0;

                System.out.println("Please enter radius of a circle");

               

                try

                {
                /**
                时代Java公众号
                **/

                        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

                        radius = Integer.parseInt(br.readLine());

                }catch(NumberFormatException ne)

                {

                        System.out.println("Invalid radius value" + ne);

                        System.exit(0);

                }

                catch(IOException ioe)

                {

                        System.out.println("IO Error :" + ioe);

                        
展开阅读全文