Compare commits
	
		
			No commits in common. "44d88bb3e7d5250531473c037ac63a9a0030615f" and "888399464e4592b2999fdbe0e6d7014e2afe9c39" have entirely different histories.
		
	
	
		
			44d88bb3e7
			...
			888399464e
		
	
		
| @ -1,6 +1,9 @@ | ||||
| package Uebungen.Uebung5; | ||||
| 
 | ||||
| import java.awt.desktop.SystemSleepEvent; | ||||
| import java.util.Scanner; | ||||
| import java.lang.Character; | ||||
| import java.util.Arrays; | ||||
| public class Aufgabe2 { | ||||
| 
 | ||||
|     public static void main(String[] args){ | ||||
| @ -9,7 +12,7 @@ public class Aufgabe2 { | ||||
|         while(true){ | ||||
|             userInterface(); | ||||
|             System.out.print("\n\n Check anoter string? [y/N]: "); | ||||
|             if(scanner.nextLine()!="y") break; | ||||
|             if(scanner.nextLine().charAt(0)!='y') break; | ||||
|             System.out.println(); | ||||
|         } | ||||
|     } | ||||
| @ -20,7 +23,6 @@ public class Aufgabe2 { | ||||
|         stringAsCharArr = normalize(stringAsCharArr); | ||||
|         char[] usedCharArr = usedChars(stringAsCharArr); | ||||
|         int[]  charAmountArr = countChars(usedCharArr ,stringAsCharArr); | ||||
|         sort(charAmountArr,usedCharArr); | ||||
|         histogramm(20,usedCharArr, charAmountArr); | ||||
|     } | ||||
| 
 | ||||
| @ -34,7 +36,7 @@ public class Aufgabe2 { | ||||
|         int max = maximum(charAmount); | ||||
|         for(int i=0;i<availableChars.length;i++) { | ||||
|             System.out.print("\""+availableChars[i]+"\": "); | ||||
|             if(max>width) // scale if max width is exceeded | ||||
|             if(max>width) | ||||
|                 for(int j=0;j<scale(charAmount[i],max,width);j++) System.out.print("#"); | ||||
|             else | ||||
|                 for(int j=0;j<charAmount[i];j++) System.out.print("#"); | ||||
| @ -46,21 +48,7 @@ public class Aufgabe2 { | ||||
|         double calc = (double) value/oldMax*newMax; | ||||
|         return (int) calc; | ||||
|     } | ||||
|     // Bubble Sort | ||||
|     public static void sort(int[] amounts, char[] chars){ | ||||
|        for(int i=amounts.length-1;i>0; i--) | ||||
|            for(int j=0;j<i;j++) | ||||
|                if(amounts[j]<amounts[j+1]) | ||||
|                    swapItems(amounts,chars,j,j+1); | ||||
|     } | ||||
|     public static void swapItems(int[] amounts, char[] chars, int index1, int index2){ | ||||
|         char memC = chars[index1]; | ||||
|         int memI = amounts[index1]; | ||||
|         chars[index1] = chars[index2]; | ||||
|         amounts[index1] = amounts[index2]; | ||||
|         chars[index2] = memC; | ||||
|         amounts[index2] = memI; | ||||
|     } | ||||
| 
 | ||||
|     public static int maximum(int[] inputArray){ | ||||
|         int largestNumber = inputArray[0]; | ||||
|         for(int i=1;i<inputArray.length;i++) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user