Hello I have a project for my class and I'm a bit stuck right now. I created a custom class with this code:
public double getTotal()
{
for (int i; i< finalTotal.length; i++)
{
sum + finalTotal[i] = sum;
}
return sum;
}//end getTotal()
The array finalTotal is created in my driver class in the method main, but my custom class that suppose to find the total of the array but, won't compile because it can't find the variable finalTotal. So how would I allow my custom class to be able to access info from the array in my driver class?
public static void main (String args[]) throws IOException
{
Checkout total = new Checkout();
double finalTotal[] = new double[10];
}//end method main
finalTotaldefined? Is it insidemainmethod? If yes, you can't access it in any other method, b'coz that is local tomainmethod. For more help, please post more code.finalTotaldeclared? Impossible to answer without more information.sum = sum + finalTotal[i];(the part on the right of=is allocated to the part on the left of=).finalTotalarray? Also, shouldn't you just callgetTotal()? And,sum += finalTotal[i];.