Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package AceptaElReto;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author mcpcm
  13. */
  14. public class Reto165 {
  15.  
  16. public static void main(String[] args) {
  17. Scanner sc = new Scanner(System.in);
  18. int contador;
  19. boolean negativo = false;
  20. while(negativo == false){
  21. String argumento = sc.nextLine();
  22. char numeros[] = argumento.toCharArray();
  23. contador = 0;
  24. if(numeros[0]!= '-'){
  25. for (int i = 0; i < numeros.length; i++) {
  26. if (numeros[i] % 2 == 0) {
  27. contador++;
  28. } else {
  29. contador = numeros.length+1;
  30. }
  31. }
  32. if (contador == numeros.length) {
  33. System.out.println("SI");
  34. } else if (contador > numeros.length){
  35. System.out.println("NO");
  36. }
  37. } else{
  38. negativo = true;
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement