Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package fse;
  6.  
  7. import java.util.Scanner;
  8.  
  9. public class Main {
  10.  
  11. static String[] tmp;
  12.  
  13. public static boolean check(String x) {
  14. if (!x.isEmpty()) {
  15. if (x.split("/").length == 3) {
  16. tmp = x.split("/");
  17. if (isNumber(tmp[0]) && isNumber(tmp[1]) && isNumber(tmp[2])) {
  18. return true;
  19. }
  20. }
  21. }
  22. return false;
  23. }
  24.  
  25. public static int[] str2int(String[] a) {
  26. int[] f = new int[a.length];
  27. for (int i = 0; i < a.length; i++) {
  28. f[i] = Integer.parseInt(a[i]);
  29. }
  30. return f;
  31. }
  32.  
  33. public static boolean isNumber(String s) {
  34. try {
  35. Integer.parseInt(s);
  36. return true;
  37. } catch (Exception e) {
  38. return false;
  39. }
  40.  
  41. }
  42.  
  43. public static void main(String[] arg) {
  44. String x = null;
  45. do {
  46. if (!check(x) && x != null) {
  47. System.out.print("MEEEEEEEEEEEEEEEC, Formato no valido");
  48. }
  49. x = new Scanner(System.in).next();
  50.  
  51. } while (!check(x));
  52. int[] yay=str2int(x.split("/"));
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement