Your code has few problems, I don't know how you got this output.
1. It is not compiling as totalNumber is not defined, I think totalNumber should be replaced with totalAverage.
2. It is not handling ArithmeticException.
I have above changes to your code and now it gives your desired result. Here is the changed code :
public class Average
{
public static void main(
String[] args)
{
printAverage(100, 0);
System.out.println("Exit main()."); //2
}
public static void printAverage(int totalSum, int totalAverage)
{
try
{
int average = computeAverage(totalSum, totalAverage);
System.out.println("Average = " + totalSum + " / " + totalAverage + " = " + average);
}
catch ( ArithmeticException a ) {}
finally
{
System.out.println("Finally done.");
}
System.out.println("Exit printAverage.");
}
public static int computeAverage(int sum, int number)
{
System.out.println("Computing average.");
return sum/number;
}
}
Regards,
Veer