Computer Science, asked by anjali2373, 10 months ago

write a program in java to separate the three digit number and display it

Answers

Answered by gurukulamdivya
2

Answer:

import java.util.Scanner;

 public class SeparatingTheDigitsInAnInteger

{

   public static void main (String [] args)

   {

       Scanner value = new Scanner (System.in);

       int number; //number entered by the user

       int digit1; //first digit of number

       int digit2; //second digit of number

       int digit3; //third digit of number

       System.out.println (); //displays a blank line

       System.out.print ("Enter An  Number Consisting of three Digits "

               + "e.g 123: ");

       number = value.nextInt();

       digit3 = number % 10;

       digit2 = (number % 10)/10;

      digit1 = number / 100;

      System.out.println ();

       System.out.printf ("%d   %d   %d   \n", digit1, digit2, digit3,  );

   }

}

I hope this helped you, So rate accordingly..

Similar questions