fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class multide3
  9. {
  10. static boolean multiplo3(int n) {
  11.  
  12. if (n % 3 == 0)
  13. return true;
  14. else return false;
  15. } // end multiplo3
  16.  
  17.  
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. Scanner input = new Scanner(System.in);
  21. System.out.println("introduce un numero");
  22. int numero = input.nextInt();
  23. // comprobar si el numero es multiplo de 3
  24.  
  25. if(multiplo3(numero))
  26. System.out.println(numero + "es multiplo de 3");
  27. else System.out.println(numero + "no es multiplo de 3");
  28.  
  29. input.close();
  30.  
  31. } // end main
  32. } // end class
Success #stdin #stdout 0.13s 58896KB
stdin
15
stdout
introduce un numero
15es multiplo de 3