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

}


Main.java:37: error: <identifier> expected
     public static double calcCirc(Radius)
                                         ^
Main.java:47: error: <identifier> expected
     public static double calcArea(radius)
                                         ^
2 errors

I've come across these 2 errors when trying to compile. Any ideas what i have done wrong to get these errors? i am rather new to java and need some assistances thank you

Recommended Answers

All 3 Replies

add datatype for Radius and radius in above method.
Certainly there are many errors in your program:-

  • In line 37 and 47 add arguement data type.

    public static double calcCirc(double Radius)//line 37
    public static double calcArea(double radius)//line 47

  • Pass radius(arguement) in line 18 and 19 to match method parameter.

         circ = calcCirc(radius );//line 18
        area = calcArea(radius );//line 19
    
  • rad seems undefined in the line 44 and line 53.As per example it should be

      circ = 2.0 * Radius * pi;//line 44
        area = pi * rad * rad;//line 53
    

I hope so you have understannd your issues in your program.

thank you, i have seem to get my program to work properly with your help.

It seems that you have already get the right answer, the error lies in that the type of the variables"Radius""radius" were not given.

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.