Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4.  
  5. public class Gruppenarbeit_Aufgabe2 {
  6.  
  7. public static void main (String [] args) {
  8. eingabeKey();
  9. }
  10.  
  11. public static String eingabeKey () {
  12.  
  13. Scanner sc = new Scanner(System.in);
  14.  
  15. System.out.println("Schlüssel eingeben");
  16. String eingabe = sc.nextLine();
  17. String kleinerText = eingabe.toLowerCase();
  18.  
  19.  
  20. if (eingabe.equals(kleinerText) && eingabe.length() == 8 && eingabe.matches ("[a-z]+") ) {
  21.  
  22. char [] ar = eingabe.toCharArray();
  23. System.out.println();
  24.  
  25. for (int i = 0; i < ar.length; i++)
  26.  
  27. {
  28. System.out.print(ar[i]);
  29. }
  30. }
  31.  
  32. else {
  33. System.out.println("kein korrekter Schlüssel");
  34. }
  35.  
  36. sc.close();
  37. return eingabe;
  38.  
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement