JAVA实现实现输入半径,输出一个星号组成的圆

/*
* @author  :Quicl
* @version    :1.0
* @email    :quicl@20xue.com
* @blog    :http://20xue.com
* @ps        :实现输入半径,输出一个星号组成的圆
*/

import java.util.Scanner;

public class XinghaoYuanClass {

    public static void main(String[] args) {

        Scanner kb = new Scanner(System.in);
        int a = kb.nextInt();
   
        graphic( a );
    }
   
    public static void graphic(int r){
       
        int y = 2 * r;
       
        int xa,xb;
        for(int R = 0;R <= y;R ++){
           
        xa = r – sp(R,r);
        xb = y – r + sp(R,r);
       
            for (int i = 0;i < xa;i ++){
                System.out.print("  ");
            }
           
            System.out.print("*");
           
            for (int i = xa + 1;i < xb;i ++){
                System.out.print("  ");
            }
           
            System.out.print("*");
            System.out.println();
           
        }
       
    }
   
    public static int sp(int R,int r){

        int s = (int) Math.sqrt(r * r – ( r – R ) * ( r – R));
        return s;
       
    }

}