WAP to find area of circle using scanner.

2 years ago
OOP Java

Compile code:

import java.util.Scanner;

    public class AreaofCircle{
    public static void main(String[] args)
    {
        int radius;
        double pi = 3.142, area;
        Scanner s = new Scanner(System.in);
        System.out.print("Enter radius of circle:");
        radius = s.nextInt();
        area = pi * radius * radius;    
        System.out.println("Area of circle is: " + area);
    }
}

 

Output:

 

 

0
Dipti KC
Jan 8, 2023
More related questions

Questions Bank

View all Questions