Sup guys, newcomer to the forums with a relatively easy question to ask. Being a relatively newcommer to Java, my first assignment was to create a simple program which asked the user to input a desired radius, and then I was to create several helper methods which used the radius as a passing argument.
I'm using Netbeans 7.2
Code goes as follows:
package circleapp; /** * * @author Alex */ import java.util.Scanner; import java.text.DecimalFormat; public class CircleApp { public static void main(String[] args) { double radius; double circ; double area; radius = getRadius(); circ = calcCirc(); area = calcArea(); DecimalFormat fmt = new DecimalFormat ("0.##"); System.out.println("The circumference of the circle is" + circ + "\n" + "The area of the circle is" + area + "\n" + "Thank you" + "for using my program"); } public static double getRadius() { double radius; Scanner scan = new Scanner(System.in); System.out.println("Enter the radius of the circle"); radius = scan.nextDouble(); return radius; } public static double calcCirc(double rad) { radius = rad; double circ; double pi; pi = 3.14159; circ = 2.0 * rad * pi; return circ; } public static double calcArea(double rad) { radius = rad; double area; double pi; pi = 3.14159; area = pi * rad * rad; return area; } }
When I debugg it, the program compiles up to the beginning step of asking me for the radius, then stops due to the error found when calling the circumference method.
Can't seem to find what is wrong with my helper methods, any ideas?