-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from KaveeshYoshitha/main
CircleAreaCalculator Added
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import java.util.Scanner; | ||
|
||
public class CircleAreaCalculator { | ||
|
||
public static double calculateArea(double radius) { | ||
return Math.PI * radius * radius; | ||
} | ||
|
||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
System.out.print("Enter the radius of the circle: "); | ||
double radius = scanner.nextDouble(); | ||
|
||
double area = calculateArea(radius); | ||
|
||
System.out.println("The area of the circle with radius " + radius + " is: " + area); | ||
|
||
scanner.close(); | ||
} | ||
} |