So this is theprogram Program #2 Write an application that inputs one number con
ID: 3613563 • Letter: S
Question
So this is theprogram
Program #2
Write an application that inputs one number consisting of fivedigits from the user, separates the number into its individualdigits and prints the digits separated from one another by threespaces each. For example, if the user types in the number42339, the program should print:
4 2 3 3 9
This is what I got doneso far
public class 5Digits {
public static void main (String [] args){
doublenum1; //first number
String input;
String output;
input =JOptionPane.showInputDialog( "Input 5 digit number." );
num1 = Double.parseDouble(input );
System.out.println( output);
System.exit( 0 );
}//main
}//5Digits
Explanation / Answer
// you have yourinput String. // add spaces in betweencharacters String output = input.replaceAll("", " "); // trim extra whitespace output=output.trim(); System.out.println(output);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.