File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
13public 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}
You can’t perform that action at this time.
0 commit comments