import java.util.Scanner; public class Program01 { public static void main(String[] args) throws Exception { String name = inputName(); checkExitRequired(name); System.out.println(name); } public static void checkExitRequired(String name) { if (!isGoodSize(name) || !isGoodString(name)) { System.err.println("Hiba! Rossz név!"); System.exit(1); } } public static String inputName() { Scanner sc = new Scanner(System.in); System.out.print("Név: "); String name = sc.nextLine(); return name; } public static boolean isGoodSize(String name) { boolean goodName = true; if (name.length()<1) goodName = false; return goodName; } public static boolean isGoodString(String name) { boolean goodName = true; if (!name.matches("[a-zA-záéíóöőúüűÁÉÍÓÖŐÚÜŰ]+")) goodName = false; return goodName; } }