Jan 28, 2019 01:46 AM
(This post was last modified: Jan 28, 2019 02:01 AM by CupOfJava.)
What I'm I missing here?
I don't get it. The Goal is to simply get the Area of a Circle that the User inputs.
I got the user input [*]
It just won't calculate the Area. It keeps giving me PI for anything I put it. I need it to Calculate the Area with the Given Radius from a user.
I'm pretty sure I'm missing something so simple What is it?
Code:
public class CircleArea {
/**
@param args the command line arguments
*/
public static void main(String[] args) {
// declare required variables
COPY THE CODE FROM HERE:
double radius, area ;
Scanner kbd = new Scanner (System.in);
// Get and show circle data
radius = 10.0;
area = 0.0;
area = Math.PI radius * radius;
// TODO: should be pi times radius squared.
//Use constant variable PI to store 3.14159
System.out.println();
System.out.println("Enter the circle radius: ");
radius = kbd.nextDouble(); //User
System.out.println("Circle Measurements");
System.out.println(" Radius: " + radius + " cm");
System.out.println(" Area: " + area + " cm squared");
}
}
Yes I have to use the Math.PI Formula Given in Java.
I don't get it. The Goal is to simply get the Area of a Circle that the User inputs.
I got the user input [*]
It just won't calculate the Area. It keeps giving me PI for anything I put it. I need it to Calculate the Area with the Given Radius from a user.
I'm pretty sure I'm missing something so simple What is it?
Code:
public class CircleArea {
/**
@param args the command line arguments
*/
public static void main(String[] args) {
// declare required variables
COPY THE CODE FROM HERE:
double radius, area ;
Scanner kbd = new Scanner (System.in);
// Get and show circle data
radius = 10.0;
area = 0.0;
area = Math.PI radius * radius;
// TODO: should be pi times radius squared.
//Use constant variable PI to store 3.14159
System.out.println();
System.out.println("Enter the circle radius: ");
radius = kbd.nextDouble(); //User
System.out.println("Circle Measurements");
System.out.println(" Radius: " + radius + " cm");
System.out.println(" Area: " + area + " cm squared");
}
}
Yes I have to use the Math.PI Formula Given in Java.


![[Image: 1kIeAJohTqeXrSrWXtGGxA.png]](https://image.prntscr.com/image/1kIeAJohTqeXrSrWXtGGxA.png)
