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 :

Enter radius : 3

The radius is : 3

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);
}
}

Re: can someone tell me if this looks right??

Quote:

//Assign a radius

double radius = input.nextInt();

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

Quote:

//Compute area

double area = radius * radius * PI;

in this line you are calculating the area.

Quote:

System.out.println("Enter radius :" + input.nextInt());

If you have already taken radius as input , then why you are asking for input in this line too.

Re: can someone tell me if this looks right??

+Rep for pointing out the cross post.

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

Enter Radius :

3

Radius is : 3.0

The Area is : 28.274333882308138

Re: can someone tell me if this looks right??

Looks right, If that's all the problem stated, then it looks done.

I'd remove the 2 tabs from the try though -- but that's just semantics.