Computer Science, asked by Anonymous, 5 months ago

Write a simple program to find a perimeter and area of circle.......

By entering the value of radius by user......

In Java

Please use scanner class....

Don't spam......

Answers

Answered by Anonymous
3

Answer:

  1. int main() { int rad;
  2. float PI = 3.14, area, ci; printf("\nEnter radius of circle: ");
  3. scanf("%d", &rad); area = PI * rad * rad;
  4. printf("\nArea of circle : %f ", area); ci = 2 * PI * rad;
  5. printf("\nCircumference : %f ", ci); return (0);

Answered by Anonymous
6

Answer:

\huge\red{\underline{{\bf A}}}\huge\orange{\underline{{\bf n}}}\huge\green{\underline{{\bf s}}}\huge\blue{\underline{{\bf w}}}\huge\purple{\underline{{\bf e}}}\huge\pink{\underline{{\bf r}}}

/*Java program to create class to calculate area and perimeter of circle.*/

import java.util.*;

class AreaOfCircle

{

private float radius=0.0f;

private float area=0.0f;

private float perimeter=0.0f;

//function to read radius

public void readRadius()

{

//Scanner class - to read value from keyboard

Scanner sc=new Scanner(System.in);

System.out.print("Enter radius:");

radius=sc.nextFloat(); //to read float value from keyboard

}

//funtction to calculate area

//return value - will return calculated area

public float getArea()

{

area= Math.PI *radius*radius;

return area;

}

//funtction to calculate perimeter

//return value - will return calculated perimeter

public float getPerimeter()

{

perimeter = 2* Math.PI *radius;

return perimeter;

}

}

public class circle

{

public static void main(String []s)

{

AreaOfCircle area=new AreaOfCircle();

area.readRadius();

System.out.println("Area of circle:" + area.getArea());

System.out.println("Perimeter of circle:" + area.getPerimeter());

}

}

Explanation:

Write a Java program to print the area and perimeter of a circle.

In geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents a constant, approximately equal to 3.14159, which is equal to the ratio of the circumference of any circle to its diameter.

The circumference of a circle is the linear distance around its edge.

if this is wrong then report ok

yes you can search more about this on Google ok

Similar questions