AreaAndCircumferenceProgram

AreaAndCircumferenceProgram - //Line 7 area = Math.PI *...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Program to determine the area and circumference of a circle / import javax.swing.JOptionPane; i public class AreaAndCircumferenceProgram { public static void main(String[] args) { double radius; //Line 1 double area; //Line 2 double circumference; //Line 3 String radiusString; //Line 4 String outputStr; //Line 5 radiusString = JOptionPane.showInputDialog("Enter the radius: "); //Line 6 radius = Double.parseDouble(radiusString);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Line 7 area = Math.PI * radius * radius; //Line 8 circumference = 2 * Math.PI * radius; //Line 9 outputStr = "Radius: " + radius + "\n" + "Area: " + area + " square units\n" + "Circumference: " + circumference + " units"; //Line 10 JOptionPane.showMessageDialog(null, outputStr, "Circle", JOptionPane.INFORMATION_MESSAGE); //Line 11 System.exit(0); //Line 12 } }...
View Full Document

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Ask a homework question - tutors are online