Thursday, October 14, 2021

Area, and Circumference of a Circle in Java

 Machine Problem

 Write a program  to ask the user to give the radius of a circle, then the program   will calculate, and display the area and circumference of the circle on the screen using Java programming language.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Program Listing

// area_circumference_circle.java

// Jake Rodriguez Pomperada,MAED-IT, MIT

// www.jakerpomperada.blogspot.com  and www.jakerpomperada.com

// jakerpomperada@gmail.com

// Bacolod City, Negros Occidental Philippines


/* 

 * Machine Problem

 * 

 * Write a program  to ask the user to give the radius of a circle, then the program

 * will calculate, and display the area and circumference of the circle on the screen.

 * 

 */


import java.util.Scanner;

import java.math.RoundingMode;

import java.text.DecimalFormat;



public class area_circumference_circle {

    

     private static DecimalFormat df2 = new DecimalFormat("#.##");


    public static void main(String[] args) {


        double radius=0.00;

        double area=0.00, circumference=0.00;

        

        Scanner scan = new Scanner(System.in);

        

              

        System.out.println();

        System.out.print("\tArea, and Circumference of a Circle in Java ");

        System.out.println("\n");

                     

        System.out.print("\tGive the Radius of the Circle : ");

        radius = scan.nextDouble();

      

        area = (3.14*radius*radius);

        

        circumference = (2 * 3.14 * radius);

      

        System.out.println("\n");

        System.out.print("\tThe Area of The Circle : " + df2.format(area));

        System.out.println("\n");

        System.out.print("\tThe Circumference of The Circle : " + df2.format(circumference));

        System.out.println("\n");

        System.out.println("\tEnd of Program");

        System.out.println();

   }

}


No comments:

Post a Comment