Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package fse;
- import java.util.Scanner;
- public class Main {
- static String[] tmp;
- public static boolean check(String x) {
- if (!x.isEmpty()) {
- if (x.split("/").length == 3) {
- tmp = x.split("/");
- if (isNumber(tmp[0]) && isNumber(tmp[1]) && isNumber(tmp[2])) {
- return true;
- }
- }
- }
- return false;
- }
- public static int[] str2int(String[] a) {
- int[] f = new int[a.length];
- for (int i = 0; i < a.length; i++) {
- f[i] = Integer.parseInt(a[i]);
- }
- return f;
- }
- public static boolean isNumber(String s) {
- try {
- Integer.parseInt(s);
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- public static void main(String[] arg) {
- String x = null;
- do {
- if (!check(x) && x != null) {
- System.out.print("MEEEEEEEEEEEEEEEC, Formato no valido");
- }
- x = new Scanner(System.in).next();
- } while (!check(x));
- int[] yay=str2int(x.split("/"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement