Question 2.10: Write a Java program to print the area and perimeter of a circle.
Test Data:
Radius = 7.5
Expected Output
Perimeter is = 47.12388980384689
Area is = 176.71458676442586
Solution:
package com.company;
import java.util.Scanner;
public class Lab2problem10 {
public static void main(String[] args)
{
Scanner Obj =new Scanner(System.in);
System.out.println("enter the radias:");
double r =Obj.nextDouble();
double pi = 3.1416;
double perimeter =2 * pi* r;
double area = pi * r * r;
System.out.println("the perimeter: " + perimeter);
System.out.println("the area: " + area);
}
}