|
|
@ -113,16 +113,16 @@ public class FunktionenAusgelagert { |
|
|
|
//5 |
|
|
|
public static void Binaerrechner() { |
|
|
|
|
|
|
|
try (Scanner scanner = new Scanner(System.in)) { |
|
|
|
try (Scanner scannerBR = new Scanner(System.in)) { |
|
|
|
System.out.print("Gebe den ersten Binärcode ein: "); |
|
|
|
String binaryCode1 = scanner.nextLine(); |
|
|
|
String binaerCode1 = scannerBR.nextLine(); |
|
|
|
System.out.print("Gebe den zweiten Binärcode ein: "); |
|
|
|
String binaryCode2 = scanner.nextLine(); |
|
|
|
String binaerCode2 = scannerBR.nextLine(); |
|
|
|
System.out.print("Gebe die gewünschte Operation ein (+, -, *, /): "); |
|
|
|
char operation = scanner.next().charAt(0); |
|
|
|
char operation = scannerBR.next().charAt(0); |
|
|
|
|
|
|
|
int result = calculate(binaryCode1, binaryCode2, operation); |
|
|
|
System.out.println("Das Ergebnis ist: " + result); |
|
|
|
int ergebnisBR = calculate(binaerCode1, binaerCode2, operation); |
|
|
|
System.out.println("Das Ergebnis ist: " + ergebnisBR); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -181,14 +181,14 @@ public class FunktionenAusgelagert { |
|
|
|
//6 |
|
|
|
public static void PrimBis100() { |
|
|
|
for (int i = 2; i <= 100; i++) { |
|
|
|
boolean isPrime = true; |
|
|
|
boolean istPrimZahl = true; |
|
|
|
for (int j = 2; j < i; j++) { |
|
|
|
if (i % j == 0) { |
|
|
|
isPrime = false; |
|
|
|
istPrimZahl = false; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isPrime) { |
|
|
|
if (istPrimZahl) { |
|
|
|
System.out.print(i + " "); |
|
|
|
} |
|
|
|
} |
|
|
|