Question :

Write a java program to find circumference and area of a circle. Your program should be fulfill following requirements.
 Radius of the circle should be read in the main method of the program
 Circumference and Area should be calculated at the circumference() and area() methods.
 Circumference and Area should be displayed at the main method.

My answer :

import java.util.Scanner;

class circles{
public static void main(String [] args){}

Scanner in = new Scanner(System.in);
int radius = in.nextInt();

circumference(radius);
area(radius);

double c1 = circumference(c);
System.out.print("Circumference of the circle is = "+c1);

double a1 = area(a);
System.out.print("Area of the circle is = "+a1);

static double circumference(int r){

double c = 2*3.14*r;
return c;
}

static double area(int r){

double a = 3.14*r*r;
return a;
}

}

Could anyone please point out the mistakes of my code?

Thanks!

looks ok

is there a reason you restrict r to integer values? Maybe because you only know about integer input?

Did you actually run it? check your results with a calculator?
As my first employer (a former NASA engineer) liked to say,
One measurement is worth a thousand expert opinions.

There are a few mistakes in your code. Here's the corrected version:

```java
import java.util.Scanner;

class Circles {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the radius of the circle: ");
int radius = in.nextInt();

double c1 = circumference(radius);
System.out.println("Circumference of the circle is: " + c1);

double a1 = area(radius);
System.out.println("Area of the circle is: " + a1);
}

static double circumference(int r){
double c = 2 * Math.PI * r;
return c;
}

static double area(int r){
double a = Math.PI * r * r;
return a;
}
}
```

Here are the changes explained:

1. The class name should start with a capital letter, so it should be `Circles` instead of `circles`.
2. The `main` method was empty. I moved the scanner and input logic inside the `main` method.
3. I added a prompt to enter the radius using `System.out.print` and `System.in.nextInt`. This will ensure that the user knows what input is expected.
4. The circle formulas should use `Math.PI` instead of a hardcoded value of 3.14 for better accuracy.
5. I changed the `System.out.print` statements to `System.out.println` to print on a new line for better readability.

These changes should make your program work as expected.

There are a few mistakes in your code:

1. The main method is empty, which means your program will not execute any code. You should move the code inside the main method.

2. The variables `c` and `a` in the `circumference()` and `area()` methods are not defined. You should pass the `radius` variable as an argument instead.

3. The `circles` class should start with a capital letter to follow the standard naming conventions in Java. It should be `Circles` instead of `circles`.

Here's the corrected code:

```java
import java.util.Scanner;

class Circles {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int radius = in.nextInt();

double c1 = circumference(radius);
System.out.println("Circumference of the circle is = " + c1);

double a1 = area(radius);
System.out.println("Area of the circle is = " + a1);
}

static double circumference(int r) {
double c = 2 * 3.14 * r;
return c;
}

static double area(int r) {
double a = 3.14 * r * r;
return a;
}
}
```

Now, when you execute the program, it will prompt you to enter the radius of the circle. After providing the radius, it will calculate the circumference and area, and display the results.