# can someone tell me if this looks right??

• January 26th, 2011, 11:19 PM
robertsbd
can someone tell me if this looks right??
these are the instructions that i was given

Write a program that calculates the area of a circle from its radius. The radius will be an integer entered via the keyboard.
Use this formula : area = PI * radius2
You will need to use the constant PI which you get by using Math.PI
A sample run would look like this :
The area is : 28.274333882308138

when i try to run the program nothing happens??

cross posted, thanks
can someone tell me if my program looks right?? - Java Forums

Code java:

```import java.util.Scanner;   public class Assign1_Roberts{ public static void main(String[]args){ Scanner input = new Scanner(System.in); //Prompt the user for input final double PI = 3.14159;//Declare a constant   //Assign a radius double radius = input.nextInt();   //Compute area double area = radius * radius * PI;   System.out.println("Enter radius :" + input.nextInt()); System.out.println("The radius is : " + radius); System.out.println("The area is: " + area);   } }```
• January 27th, 2011, 12:34 AM
DanBrown
Re: can someone tell me if this looks right??
Quote:

In this line you are asking for input from the user.

Quote:

//Compute area
in this line you are calculating the area.

Quote:

If you have already taken radius as input , then why you are asking for input in this line too.
• January 27th, 2011, 04:40 AM
JavaPF
Re: can someone tell me if this looks right??
+Rep for pointing out the cross post.
• January 27th, 2011, 11:05 AM
robertsbd
Re: can someone tell me if this looks right??
alright here is my updated code..and my out put will be posted at the bottom...getting the correct results just tell me if I am on the right track thanks

Code java:

```import java.io.*; public class Assign1_Roberts{ public static void main(String[] args){ double radius = 0; try{ BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Radius : "); radius = Integer.parseInt(br1.readLine()); System.out.println("Radius is : " + radius); double area = java.lang.Math.PI*radius*radius; System.out.println("The Area is : "+area);   } catch(Exception e){ System.out.println("Error : "+e); } } }```