File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed
Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 33public class Exercise {
44
55 public static void main (String [] args ) {
6- @ SuppressWarnings ("resource" )
7- Scanner sc = new Scanner (System .in );
6+ @ SuppressWarnings ("resource" )
7+ Scanner sc = new Scanner (System .in );
88
9- System .out .print ("Gib bitte eine Zeichenkette ein: " );
10- String text = sc .nextLine ();
9+ System .out .print ("Gib bitte eine Zeichenkette ein: " );
10+ String text = sc .nextLine ();
1111
12- System .out .print ("Gib bitte das zu analysierende Zeichen ein: " );
13- char token = sc .next ().charAt (0 );
12+ System .out .print ("Gib bitte das zu analysierende Zeichen ein: " );
13+ char token = sc .next ().charAt (0 );
1414
15- int count = 0 ;
16- for (int i = 0 ; i < text .length (); i ++) {
17- if (text .charAt (i ) == token ) {
18- count ++;
19- }
20- }
15+ int count = 0 ;
16+ for (int i = 0 ; i < text .length (); i ++) {
17+ if (text .charAt (i ) == token ) {
18+ count ++;
19+ }
20+ }
2121
22- double percentage = count * 100 / text .length ();
22+ double percentage = count * 100 / text .length ();
2323
24- System .out .printf ("Absoluter Anteil: %d%n" , count );
25- System .out .printf ("Prozentualer Anteil: %.2f%%%n" , percentage );
24+ System .out .printf ("Absoluter Anteil: %d%n" , count );
25+ System .out .printf ("Prozentualer Anteil: %.2f%%%n" , percentage );
2626 }
2727}
You can’t perform that action at this time.
0 commit comments