Write a program that accepts a four digit number, such as 1998, and displays it on number on a line, like: 1 9 9 8 The program should prompt for a four digit number. The program assumes that the user enters the correct information. Provide the java code, including a comment with your name, course code and date.

Respuesta :

package brainly;

import java.util.*;

/**

*

* @author CotrinaAlejandra

*/

public class Brainly {

   /*Provide the java code, including a comment with your name, course code and date.

   Name:  

   Course:  

   Date: */

   public static void main(String[] args) {

       // TODO code application logic here

       int number;

       Scanner sc = new Scanner(System.in);

       System.out.print("Write a four digit number: ");

       number=sc.nextInt();

       String newLine= String.valueOf(number);

       System.out.println(newLine.charAt(0)+"  "+newLine.charAt(1)+"  "+newLine.charAt(2)+"  "+newLine.charAt(3));

       

       

   }

   

}

Ver imagen ANCKPOP