Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have alre
ady been declared, use a for loop to compute the sum of the cubes of the first n whole numbers, and store this value in total. Use no variables other than n, k, and total.
Here the variable total is declared and initialized with a value zero
Then a for loop is defined with a counter k whose initial value is set to zero then a condition for the loop is that the counter k does not exceed n k<=n and then within the loop a statement which add the cube of the counter k to the variable total and still assigns it to the variable total is defined
total += Math.pow(k,3);
What this program does is to obtain the sum of the cubes of k