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.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
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 (System.in);
int nos, sl;
System.out.println(“enter the number of sides”);
nos = sides.nextInt();
writer.println(nos);
System.out.println(“enter the length of the sides”);
sl = sides.nextInt();
writer.println(sl);
double area = pentegon();
System.out.println(“area of the pentagon=”+ area);
writer.println(area);
writer.close();
}
static double pentegon(int sl) {
double A = (5 * Math.pow(sl, 2)) / (4 * Math.tan(Math.PI /5));
return A;
}
}