**Area of a circle = ****πR ^{2} **

**Where π = 3.14 and R = radius of circle**

**Example**:

Radius = 4.0 Area = π*radius*radius = 3.14*4*4 = 50.24

**Code**:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.

Learn more about bidirectional Unicode characters

public class AreaOfCircle { | |

public static void area(double radius){ | |

double pi = 3.14; | |

double area = pi*radius*radius; | |

System.out.println("Area of circle with radius="+radius + " is: " + area); | |

} | |

public static void main(String[] args) { | |

double radius = 4; | |

area(radius); | |

} | |

} |

**Output**:

Area of circle with radius=4.0 is: 50.24

Area is calculated incorrectly

double area = 2*pi*radius;

should be

double area = pi * radius * radius

and the Out put should be 50.24 instead of 25.12

Thanks Lipsa. We have modified the code