Java programming
Write a program to accept radius of a circle as parameter.lf the radius is greater than 12 then calculate and display the circle area.
Answers
The given problem is solved using language - Java.
public class Brainly{
public static void main(double r){
System.out.println("Radius of the circle: "+r+" unit.");
if(r>12){
double a=Math.round(Math.PI*r*r*100)/100.0;
System.out.println("Area of the circle is: "+a+" square unit.");
}
else
System.out.println("Radius is less than 12 unit.");
}
}
- Accept the radius from the user.
- If radius > 12, then display the area of the circle.
- If radius < 12, then display an appropriate message.
See the attachments for output.
Answer:
Program:-
import java.util.*;
public class Main
{
void area(int radius)
{
double ar=0;
if(radius>12)
{
ar=22.0/7.0*radius*radius;
System.out.println("The area of circle="+ar);
}
else
System.out.println("Wrong Input");
}
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
Main ob=new Main();
int r;
System.out.println("Enter the radius of the circle");
r=in.nextInt();
ob.area(r);
}
}