From 3f54647d5365b28784d48f9db80d3d78f591069d Mon Sep 17 00:00:00 2001 From: jannisfingerhut Date: Fri, 10 Feb 2023 02:25:00 +0100 Subject: [PATCH] Funktion SchaltjahrBerechnung erstellt 2, da Fehler --- LernProgramm/ProgrammMain.java | 44 +++++++++++++----- .../ProgrammMain$FactorialCalculator.class | Bin 0 -> 1331 bytes bin/LernProgramm/ProgrammMain.class | Bin 1184 -> 6938 bytes 3 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 bin/LernProgramm/ProgrammMain$FactorialCalculator.class diff --git a/LernProgramm/ProgrammMain.java b/LernProgramm/ProgrammMain.java index 778446c..a81ef88 100644 --- a/LernProgramm/ProgrammMain.java +++ b/LernProgramm/ProgrammMain.java @@ -154,30 +154,50 @@ 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); - - String jahr = scanner2.nextLine(); - int jahr1 = Integer.parseInt(jahr); - + try (Scanner scanner2 = new Scanner(System.in)) { + String jahr = scanner2.nextLine(); + int jahr1 = Integer.parseInt(jahr); + // Bestimmen+Ausgabe - - if( jahr1 % 400 == 0 ) System.out.println("Schaltjahr!"); - 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!"); + + if( jahr1 % 400 == 0 ) System.out.println("Schaltjahr!"); + 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) { diff --git a/bin/LernProgramm/ProgrammMain$FactorialCalculator.class b/bin/LernProgramm/ProgrammMain$FactorialCalculator.class new file mode 100644 index 0000000000000000000000000000000000000000..028af209f549fad96e0333a33d45605c6266de9b GIT binary patch literal 1331 zcmaJ=TTc^F5dKcPbj!L3l$+3sMT)i{)C*qQdZAjWDPU65#Q1b5M_AnMlI@nnHy`{P zBpNY1h$fm?j3)j7|Bz2!<}BqV#Wb1DoHP5)H{Y50@%!s{05|bKg^yvpAROzVV=p?q zQc3POGu*IZIbL>c$KYm`o8_9xDNvy>bS(2#o;10&n4Ftm7G;+q;4T@}*m;I<;Yhp` zrKJtaaBngU#{ZL-C^0BmdqK2<;h2sV1T^^3rbESX27g>8v=bNbNQ&*&@COw$Kokbd(t|rgMpcU5wBbRtAis~o!q!VAil z6~Y5+Xi+wmw369?7LF{XU;0>NVExa}@FrdRJ;*^S4ZMPa*98BDXsn|RZwYoC{n+qI zMYrM5gI>xFQmH=jNI60{L7tB?B?W)r7Xpk0$Q?kq!Nw+N$z~*&4u3%;^9h6B5PMAi znJt_PCF{5lspE1T*Xl^`wHl(&fOmwwNeti95PjIkWdwIHMfW}od#t2@gB~l{de*zS Si+l7hmy#ieX|j3mJogt+?=nsR literal 0 HcmV?d00001 diff --git a/bin/LernProgramm/ProgrammMain.class b/bin/LernProgramm/ProgrammMain.class index 91962de923ae7222f94ca26a42c41aaa66d52c70..7e85d8662f33f7b0bdce551830931688916f25cb 100644 GIT binary patch literal 6938 zcmbtZ3wRXQb^fpRH4=*j0wE-X8DX%c)e~V08wrda2!tMB77Gi4^GCKgqfRcI{JunVd}yYE_?QHhUw~-t!M1C>6l}B zG(`*8Y45OHYP~{eS7zLDO-I8G3aj^Xe!|Eq(Vwynz0XP;`iMDZBwfna(4KuJ`<-}7 zj~n`+WydTHwF(iL>8a0mN5+nu=~2Tzk>uBvC#Y9gv^!}W)}ygRDtSU2(ilb)HV`AJ z3?VaT`#rSVob5N_rVwtVZS$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