Output:import java.util.*; import java.io.*; class Cubesum { public static void main(String args[]){ int input=0; int num1,num2,num3; //read the number System.out.print("Enter a positive integer: "); Scanner console = new Scanner(System.in); input= Integer.parseInt(console.nextLine()); int number = input; //number is a temp variable int counter = 0; //counter is used to count no of digits while(number>0){ int t= number%10; counter += t * t * t; number = number/10; } System.out.println("The sum of the cubes of the digits is: "+counter); } }
Enter a positive integer: 223
The sum of the cubes of the digits is: 43
I want to get this output from the program:
371 = 3³+7³+1³
How would I do it?