Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * cube
- */
- public class cube {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("enter a numeber"); // taking input from user
- int a = sc.nextInt();
- cube ob = new cube();
- ob.chekc(a);
- }
- void chekc(int a) {
- int l = a * a * a; // cuubing the number
- int sum = 0;
- while (l != 0) {
- sum += l % 10;
- l = l / 10;
- }
- if (sum == a) { // checking for number
- System.out.println("sum of digits of cube is number");
- } else
- System.out.println("sum of digits of cube is not number");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment