I've tried to define result many different ways, but I just can't get it to work. I know it's just something simple I am missing, but what is it? Can someone point me in the right direction? It currently says 'variable result might not have been initialized'.. but if I take out int result; in the findBestFit, it just shows four more errors saying it cannot find symbol variable result.
import java.util.Scanner;
public class folderSize
{
public folderSize()
{
System.out.print("Specify the size of the destination folder: ");
Scanner kboard = new Scanner(System.in);
int folder = kboard.nextInt();
System.out.print("Enter the size of the first file: ");
int size1 = kboard.nextInt();
System.out.print("Enter the size of the second file: ");
int size2 = kboard.nextInt();
int result = findBestFit(size1, size2, folder);
}
public int findBestFit(int size1, int size2, int folder)
{
int result;
if (size1 + size2 < folder)
{
result = 3;
}
else if (size2 < folder)
{
result = 2;
}
else if (size1 < folder)
{
result = 1;
}
return result;
}
}