Machine Problem

 Write a program that input from the user the radius of a circle as an integer and prints the circle's circumference and area using the predefined constant Math.PI.

Use the following formulas (r is the radius):

circumference = 2 PI r

area = PI r 2

 

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.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

=================================================



Want to support my channel?

GCash Account

Jake Pomperada


09173084360



Paypal

https://paypal.me/jakerpomperada



Patreon

https://www.patreon.com/jakerpomperada

Thank you very much for your support.

/* Write a program that input from the user the radius of a circle
as an integer and prints the circle's circumference and area
using the predefined constant Math.PI.

Use the following formulas (r is the radius):
circumference = 2 PI r
area = PI r 2
 * 
 */

import javax.swing.JOptionPane;
import java.text.DecimalFormat;
import java.lang.Math;  

public class Area_Circle {
	
	 private static final DecimalFormat df = new DecimalFormat("0.00");

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		// TODO Auto-generated method stub
		  String r = 

			         JOptionPane.showInputDialog( "Enter the radius of the circle:  " );
			       double radius = Double.parseDouble(r); 
			      		      			      
			     //Area = PI*radius*radius			      
			      double area=(Math.PI*(radius*radius));  
			      //Circumference = 2*PI*radius
			      double circumference= Math.PI * 2*radius;
			      
			      JOptionPane.showMessageDialog( null,  "The Area of the Circle :  " + df.format(area) + "\n"
			    		    + "The Circumference of the Circle :  " + df.format(circumference)
				    	    , "The Result", JOptionPane.INFORMATION_MESSAGE );

	}

}

Leave a Reply

Your email address will not be published.