AreaOfCircle - double r = readDouble("Enter...

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

View Full Document Right Arrow Icon
/* * File: AreaOfCircle.java * --------------------- * This program prompts for the radius of a circle, * then prints the area of the circle. * * Author: CS1MD3, Sept. 2008 */ import acm.program.*; public class AreaOfCircle extends ConsoleProgram { public void run() { println("This program calculates the area of a circle.");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: double r = readDouble("Enter radius: "); //* Prompts for radius double a = PI*r*r; //* Computes the area by the formula println("The area of the circle is " + a + "."); } /* constant PI */ private static final double PI = 3.1415926535897932; }...
View Full Document

Ask a homework question - tutors are online