Area of Circle

 Area of Circle


Problem Description


Java Program to find area of circle


Note:


Use Double Data Type


and Use the following statements in the output


String.format("%.02f",area)

Logic Test Case 1


Input (stdin)

2


Expected Output


12.57

Logic Test Case 2


Input (stdin)

9


Expected Output


254.47




Code Area


import java.io.*;

import java.util.Scanner;

 public class TestClass {

public static void main(String[] args) 

     {

       int r;

       double pi=3.14159,area;

       Scanner in=new Scanner(System.in);

       r=in.nextInt();

       area=pi*r*r;

       String str1=String.format("%.02f",area);

       System.out.println(str1);

       }

}


Post a Comment

0 Comments