Code :

import java.util.Scanner; public class CubesSum { public static void main (String [] args){ int input; System.out.println("Enter a positive integer:"); Scanner in = new Scanner(System.in); input = in.nextInt(); int number = input; //number is a temp variable int sum = 0; while(number>0){ int t= number%10; sum += t*t*t; number = number/10; } System.out.println("The sum of the cubes of the digits is:" +sum); } }

As you can see I'm using a while loop. For part B which is to modify to determine what integers of two, three, and four digits are equal to the sum of the cubes of their digits. So for example, 371 = 3³+7³+1³. Can someone tell me how to do it? I need to wrap a for loop around my while loop...