Results 1 to 4 of 4
  1. #1
    jangeles323 is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default new to java and got 2 errors

    Java Code:
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class Main
    {
     
     
     
     
     
        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("run \n " + "The circumference of the circle is \n" + circ 
                       + "The area of the circle is \n" + area);
     
            }
     
         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(Radius)
         {
     
             double circ;
             double pi;
             pi = 3.14159;
     
             circ = 2.0 * rad * pi;
             return circ;
         }
         public static double calcArea(Radius)
         {
             double area;
             double pi;
             pi = 3.14159;
     
             area = pi * rad * rad;
             return area;
         }
    	  
    }
    and these are the errors

    Main.java:37: error: <identifier> expected
    public static double calcCirc(Radius)
    ^
    Main.java:47: error: <identifier> expected
    public static double calcArea(radius)
    ^
    I am suppose to write a simple program that will calculate the Circumference and Area of a circle using the entered number from the radius. I thought i returned them properly but seem to be stuck with these errors.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,940
    Rep Power
    8

    Default Re: new to java and got 2 errors

    You have a single word "Radius" as a parameter. That's not correct syntax.

    Recommended reading: Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    356
    Rep Power
    5

    Default Re: new to java and got 2 errors

    You are missing the data type for your Radius variable. Also, keep in mind with java coding conventions, variables are lowercase.

  4. #4
    jangeles323 is offline Member
    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Default Re: new to java and got 2 errors

    Okay i fixed my mistakes and its working as it should be. Thank you for your help

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  2. Second week into Java - errors
    By hayden06f4i in forum New To Java
    Replies: 9
    Last Post: 11-03-2010, 05:01 PM
  3. Java errors
    By AMYVALMARK in forum New To Java
    Replies: 2
    Last Post: 01-18-2010, 06:30 PM
  4. Replies: 3
    Last Post: 03-08-2009, 01:51 AM
  5. Java Errors! Please help!
    By TearsOfTheMoon in forum New To Java
    Replies: 2
    Last Post: 06-10-2008, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •