lesson 2.1 exercise a

package lesson.pkg1; /** * * @author anfal */ public class computeArea { public static void main(String[] args) { //writing a simple program //program that calculates the area of a circle with radius 5 //1. int radius = 5 int radius = 5; //2. double area double area; //3. area <-- radius * radius * PI area = radius * radius * Math.PI; area = Math.pow(radius, 2) * Math.PI; //4. print area System.out.println("the circle of radius: " + radius + ", has the area of: " + area + "."); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.