Computer Science, asked by Atlas99, 1 month ago

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

Answered by anindyaadhikari13
9

\textsf{\large{\underline{Solution}:}}

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.");

   }

}

\textsf{\large{\underline{Logic}:}}

  • 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.

Attachments:

anindyaadhikari13: Thanks for the brainliest ^_^
Answered by kamalrajatjoshi94
3

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);

}

}

Attachments:
Similar questions