How do I write an application that prompts the user to input a five digit number, and prints the digits separated from each other by three spaces each? (For example, the user enters "61345" and the program prints "6 1 3 4 5").
Here is the initial program skeleton to work from:
import java.util.Scanner;
public class SpaceNumber {
public static void main(String args[]) {
// get a number from user - store in variable called number
Scanner input = new Scanner(System.in);
System.out.print( "Enter a positive, 5-digit integer: " );
int number = input.nextInt();
// Notes: (1) above code assumes user actually enters an integer;
// (2) code below assumes the integer has 5 digits and is > 0.
//YOUR SOLUTION HERE
}
}
I'd really appreciate the help. I'm just starting java and the textbook doesn't clearly specify how to complete this problem.
2006-10-16
09:44:48
·
5 answers
·
asked by
boatboatboat
1
in
Computers & Internet
➔ Programming & Design