Notification texts go here Contact Us Buy Now!

Complete the code segment to find the perimeter and area of a circle given a value of radius. You should use Math.PI constant in your program. If radius is zero or less than zero then print " please enter non zero positive number ".

Complete the code segment to find the perimeter and area of a circle given a value of radius. You should use Math.PI constant in your program. If rad

 import java.util.Scanner;  

public class Exercise1_1 {

       public static void main(String[] args) {

Scanner s = new Scanner(System.in); 

       double radius= s.nextDouble();

       double perimeter;

       double area;


//Calculate the perimeter 

  //Calculate the area


// final double PI = 3.14159;

  perimeter = 2 * Math.PI * radius;


  area = Math.PI * radius * radius;


System.out.println(perimeter);

System.out.print(area);

    if(radius == 0)

    {


        System.out.println(" please enter non zero positive number "); 


    }

 }

}

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.