|
|
@ -154,14 +154,31 @@ public class ProgrammMain { |
|
|
|
return binary; |
|
|
|
} |
|
|
|
|
|
|
|
public class FactorialCalculator { |
|
|
|
|
|
|
|
public static int calculateFactorial(int number) { |
|
|
|
if (number <= 0) { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
int result = 1; |
|
|
|
for (int i = 1; i <= number; i++) { |
|
|
|
result *= i; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
int number = 5; |
|
|
|
int result = calculateFactorial(number); |
|
|
|
System.out.println(number + "! = " + result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void schaltjahr() { |
|
|
|
|
|
|
|
System.out.println("Welches Jahr möchtest du untersuchen?"); |
|
|
|
|
|
|
|
Scanner scanner2 = new Scanner(System.in); |
|
|
|
|
|
|
|
try (Scanner scanner2 = new Scanner(System.in)) { |
|
|
|
String jahr = scanner2.nextLine(); |
|
|
|
int jahr1 = Integer.parseInt(jahr); |
|
|
|
|
|
|
@ -172,12 +189,15 @@ public class ProgrammMain { |
|
|
|
else if( jahr1 % 100 == 0 ) System.out.println("Kein Schaltjahr!"); |
|
|
|
else if( jahr1 % 4 == 0 ) System.out.println("Schaltjahr!"); |
|
|
|
else System.out.println("Kein Schaltjahr!"); |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
|
|
|
|