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