Thursday 6 December 2018

Java Program to find Area of Circle


AIM:

Write a simple JAVA program to find area of circle.

ALGORITHM :

Step 1: Start

Step 2: Input the radius.

Step 3: Create the object and pass the radius to it.

Step 4: Call the area method from main and print the result.

Step 5: Stop.

PROGRAM :

import java.io.*;

class Circle{

double r;

Circle(){

r=0;

}

Circle(double a){

r=a;

}

void Area(){

double a;

a=3.14*r*r;

System.out.println("Area of cicle is "+ a);

}

}

}

classAreaCircle{

public static void main(String args[])throws IOException{

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

System.out.println("Enter the radius:");

int r=Integer.parseInt(br.readLine());

System.out.println(r);

Circle c1=new Circle(r);

c1.Area();

}

}

OUTPUT :

Enter the radius:

3

Area of cicle is 28.259999999999998


No comments:

Post a Comment

How to Invert an SVG image using CSS ?

You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...