Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote