Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CircleAreaCalculator {
- private double radius;
- public void getInput() {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Enter the radius of the circle: ");
- radius = scanner.nextDouble();
- }
- public double calculateArea() {
- return Math.PI * radius * radius;
- }
- public void displayResult() {
- System.out.println("The area of the circle is: " + calculateArea());
- }
- public static void main(String[] args) {
- CircleAreaCalculator calculator = new CircleAreaCalculator();
- calculator.getInput();
- calculator.displayResult();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement