Originally Posted by
Zaphod_b
...
//Create a public class with whatever appropriate name you choose.
//Here's what goes in the class:
//Make three functions:
static int f1(int n)
{
// Calculate the sum of the first n integers.
// Maybe with a for(){} loop.
// Return the square of that sum.
} // End of f1()
static int f2(int n)
{
// Calculate the value of n times (n+1) divided by 2.
// Return that value.
} // End of f2()
static int f3(int n)
{
// Calculate the sum of the cubes of the first n integers.
// Maybe with a for(){} loop.
// Return that sum.
} // End of f3()
static void main(String [] args)
{
// Make a for(){} loop that lets an integer variable, n, go
// from 1 through 20.
//
// Here's the body of that loop.
//
BEGIN LOOP
// Declare integer variables sum1, sum2, sum3.
//
// Let sum1 = f1(n), sum2 = f2(n) and sum3 = f3(n).
//
// Print values of n, sum1, sum2, sum3.
END LOOP
} // End of main()
Cheers!
Z
Cool of you to take the time for that for someone
Two thumbs up for nice people