Originally Posted by
bluegreen7hi
Well, here's what I came up with. For the average, instead of assigning double to each integer, I just divided by (double)5. Here it is:
public class Math
{
static int a = 53;
static int b = 40;
static int c = 36;
static int d = 12;
static int e = 27;
public static void computeSum()
{
System.out.println("The Sum Is:");
System.out.println(a + b + c + d + e);
}
public static void computeAverage()
{
System.out.println("The Average Is:");
System.out.println((a + b + c + d + e) / (double)5);
}
public static void main(String[] args)
{
computeSum();
computeAverage();
}
}
Compiles and runs perfectly, displaying the correct 33.6 as the average. Thanks for all your help.
Lol, yep, that works too. Congratulations, you've just hacked.

What I said about up and down casting still holds.. which, from what I gather you might already have an idea about. As you've just proven, there's many ways to do one task, especially in Java and the route you take for that task can depend on any number of factors(design, taste, etc.).
Good job.
