completed task 3
This commit is contained in:
		
							parent
							
								
									44d88bb3e7
								
							
						
					
					
						commit
						e1ea1d2e75
					
				| @ -2,7 +2,6 @@ package Uebungen.Uebung5; | ||||
| import java.util.Scanner; | ||||
| import java.lang.Character; | ||||
| public class Aufgabe2 { | ||||
| 
 | ||||
|     public static void main(String[] args){ | ||||
|         // initiate scanner for input | ||||
|         Scanner scanner = new Scanner(System.in); | ||||
| @ -23,13 +22,11 @@ public class Aufgabe2 { | ||||
|         sort(charAmountArr,usedCharArr); | ||||
|         histogramm(20,usedCharArr, charAmountArr); | ||||
|     } | ||||
| 
 | ||||
|     public static char[] normalize(char[] workerArray){ | ||||
|         for(int i=0; i<workerArray.length;i++) | ||||
|             workerArray[i]=Character.toLowerCase(workerArray[i]); | ||||
|         return workerArray; | ||||
|     } | ||||
| 
 | ||||
|     public static void histogramm(int width, char[] availableChars, int[] charAmount){ | ||||
|         int max = maximum(charAmount); | ||||
|         for(int i=0;i<availableChars.length;i++) { | ||||
| @ -40,7 +37,6 @@ public class Aufgabe2 { | ||||
|                 for(int j=0;j<charAmount[i];j++) System.out.print("#"); | ||||
|             System.out.println("x"+charAmount[i]); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
|     public static int scale(int value, int oldMax, int newMax){ | ||||
|         double calc = (double) value/oldMax*newMax; | ||||
| @ -98,7 +94,6 @@ public class Aufgabe2 { | ||||
|                 targetArray[targetPosition] = currChar; // add the current char | ||||
|                 targetPosition++; // we added a new char, so we need to increment for the next one | ||||
|             } | ||||
| 
 | ||||
|         return targetArray; | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										28
									
								
								GDP_Gesamt/src/Uebungen/Uebung5/Aufgabe3.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								GDP_Gesamt/src/Uebungen/Uebung5/Aufgabe3.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| package Uebungen.Uebung5; | ||||
| 
 | ||||
| public class Aufgabe3 { | ||||
|     public static void main(String[] args){ | ||||
|         int[] myArray = {1,2,3}; | ||||
|         outputArray(myArray); | ||||
|         myArray = anfuegen(myArray, 4); | ||||
|         outputArray(myArray); | ||||
|     } | ||||
|     // | ||||
|     public static int[] anfuegen(int[] inputArray, int addedInt){ | ||||
|         int[] outputArray = new int[inputArray.length+1]; | ||||
|         for(int i=0;i<inputArray.length;i++) | ||||
|             outputArray[i] = inputArray[i]; | ||||
|         outputArray[inputArray.length]=addedInt; | ||||
|         return outputArray; | ||||
|     } | ||||
| 
 | ||||
|     public static void outputArray(int[] inputArray){ | ||||
|         System.out.print("["); | ||||
|         for(int i=0;i<inputArray.length;i++) | ||||
|             if(inputArray.length-1==i) | ||||
|                 System.out.print(inputArray[i]); | ||||
|             else | ||||
|                 System.out.print(inputArray[i]+" ,"); | ||||
|         System.out.println("]"); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user