beginner in java, eclipse, calling variables back to main

im supposed to find the area of a pentegon in a methed and call it back to main so it can be printed to a txt file. i got the everything to work in the main perfectly then when i tried break it up and put the area equation into a method i keep getting this error “The method pentegon(int) in the type ABhw4part4 is not applicable for the arguments ()”

 at the line of code “double area = pentegon();”

(ABhw4part4 is the project name)

somthing seems to go wrong when i try calling the answer to the equation back to the main

im having a similar problem with another problem involving strings and char

id be grateful for any help

import java.util.Scanner;

public class ABhw4part4 {

public static void main(String[] args) throws IOException {

/* Write a method to calculate the area of a pentagon.

Call this method from MAIN and print the result.
Create a file and write all data to the file.

Expected Output:

Input the number of sides: 5
Input the side: 6
The area of the pentagon is 61.93718642120281
Expected file content:
Number of sides: 5
Side: 6*/

File myFile = new File(“C://temp//ABhw4part4.txt”);

if (myFile.createNewFile() == true) {
System.out.println(“file is created”);
} else {
System.out.println(“file already exists”);
PrintWriter writer = new PrintWriter(myFile);
Scanner sides = new Scanner (;
int nos, sl;

System.out.println(“enter the number of sides”);
nos = sides.nextInt();

System.out.println(“enter the length of the sides”);
sl = sides.nextInt();

double area = pentegon();
System.out.println(“area of the pentagon=”+ area);

static double pentegon(int sl) {
double A = (5 * Math.pow(sl, 2)) / (4 * Math.tan(Math.PI /5));
return A;

1 Like

Review how to call functions, especially regarding the passing of parameters.


lets build together. I am searching for some guys who can help me making apps with java