Advertisement
LynchzDEV

Circle Area Calculator

Jul 2nd, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CircleAreaCalculator {
  4.     private double radius;
  5.  
  6.     public void getInput() {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         System.out.print("Enter the radius of the circle: ");
  10.         radius = scanner.nextDouble();
  11.     }
  12.  
  13.     public double calculateArea() {
  14.         return Math.PI * radius * radius;
  15.     }
  16.  
  17.     public void displayResult() {
  18.         System.out.println("The area of the circle is: " + calculateArea());
  19.     }
  20.  
  21.     public static void main(String[] args) {
  22.         CircleAreaCalculator calculator = new CircleAreaCalculator();
  23.         calculator.getInput();
  24.         calculator.displayResult();
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement