Hi all I am enrolled in abeginners class and am having problems with methods. I keep getting a .class expected and do not know how to fix this. It is at this line that the message appears total = Circle.area(int radius);.

import javax.swing.JOptionPane;

public class Circle
{
   public static void main(String [] args)
   {
      // double area; ////area to be determined in a method
       double radius; //radius inputted by user
       String input; //for holding user input    
       double total;//final area of a circle

       //Ask the user for a radius or a circle
     input= JOptionPane.showInputDialog("Please enter the radius of the circle ");

       //Convet the string input to a double
       radius=Double.parseDouble(input);

       // this calls the circle method
       total = Circle.area(int radius);

       JOptionPane.showMessageDialog(null,"The area of the circle is "+total );
    }
       /*
        * The Area method returns the area of the circle
        * @param rad the radius inputted by the user
        * @param Math.PI the math class
        * @return The area of the circle
        */
       public  static double area (double rad)
       { 
         double area;
         area=Math.PI * (rad*rad);
         return area;
        }

    }

Recommended Answers

All 5 Replies

I fixed the int in the method call to a double and it still will not work

*code tags expected. Redo from start*

remove the "int" and/or "double" now, from the call to the method. You include types when defining and declaring the methods. You include only values when calling the methods.

Thank you very much.

Sorry about the format.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.