Computer Science, asked by suyashsingh21369, 1 month ago

write a java program to input a number and finds its expanded form. Using while loop​

Answers

Answered by CoderRishav
3

Answer:

Sample Input - 204

Output - 2 X 100 + 0 X 10 + 4 X 1

import java.util.Scanner;

class Expanded

{

public static void main()

{

Scanner in = new Scanner(System.in);

int num = in.nextInt();

String str = "";

int c = 0;

while (num != 0)

{

str = "+" + (num%10) + "X" + ((int)Math.pow(10,c)) + str;

c++;

num /= 10;

}

System.out.print(str.substring(1));

}

}

Similar questions