Skip to content

Commit f9ee998

Browse files
committed
implement solution
1 parent 8e55ee8 commit f9ee998

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Exercise.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
1+
import java.util.Scanner;
2+
13
public class Exercise {
24

35
public static void main(String[] args) {
4-
// implement exercise here
6+
@SuppressWarnings("resource")
7+
Scanner sc = new Scanner(System.in);
8+
9+
System.out.print("Gib bitte die erste Zeichenkette ein: ");
10+
String input1 = sc.nextLine();
11+
12+
System.out.print("Gib bitte die zweite Zeichenkette ein: ");
13+
String input2 = sc.nextLine();
14+
15+
boolean identical = true;
16+
17+
if (input1.length() != input2.length()) {
18+
identical = false;
19+
}
20+
21+
if (identical) {
22+
for (int i = 0; i < input1.length(); i++) {
23+
char char1 = input1.charAt(i);
24+
char char2 = input2.charAt(i);
25+
char1 = Character.toUpperCase(char1);
26+
char2 = Character.toUpperCase(char2);
27+
if (char1 != char2) {
28+
identical = false;
29+
break;
30+
}
31+
}
32+
}
33+
34+
System.out.println(identical ? "Die beiden Zeichenketten sind identisch"
35+
: "Die beiden Zeichenketten sind nicht identisch");
36+
537
}
638
}

0 commit comments

Comments
 (0)