Posted by: Slackdemic September 16, 2006
Java help
Login in to Rate this Post:     0       ?        
Pat, that hollywood and bollywood thing is the "ghush" or just wanted to give away something to the one who helps you? If you really want to java, then JAVA! No hollywood or bollywood! : Here's it anyway. Hope it helps. :) import java.util.Scanner; public class NumberOutput { public static void main( String args[]) { int number; int digit1; int digit2; int digit3; int digit4; Scanner input = new Scanner( System.in ); System.out.print( "Enter the number: "); number = input.nextInt(); digit1 = number / 1000; digit2 = number % 1000 / 100; digit3 = number % 1000 % 100 / 10; digit4 = number % 1000 % 100 % 10; System.out.printf("\nThe first digit is: %d", digit1 ); System.out.printf("\nThe second digit is: %d", digit2 ); System.out.printf("\nThe third digit is: %d", digit3 ); System.out.printf("\nThe fourth digit is: %d\n", digit4 ); } }
Read Full Discussion Thread for this article