+Jasmins Version EinkaufwagenNummer

master
BuildTools 4 years ago
parent 60dd113db4
commit 384bfd3c1d

@ -16,11 +16,17 @@
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
<select>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="BRANCH:master" type="e8cecc67:BranchNodeDescriptor" />
</path>
</select>
</component>
<component name="ChangeListManager">
<list default="true" id="86f42963-ed9f-4d18-9c81-a4cf18fa27c4" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<list default="true" id="86f42963-ed9f-4d18-9c81-a4cf18fa27c4" name="Default Changelist" comment="EinkaufwagenNummer FERTIG">
<change afterPath="$PROJECT_DIR$/src/com/company/EinkaufwagenNummerJasminFehler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/com/company/EinkaufswagenNummer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/com/company/EinkaufswagenNummer.java" afterDir="false" />
</list>
@ -29,6 +35,13 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
@ -41,7 +54,7 @@
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
</component>
<component name="RunManager">
<component name="RunManager" selected="Application.EinkaufwagenNummerJasminFehler">
<configuration name="EinkaufswagenNummer" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.company.EinkaufswagenNummer" />
<module name="JAVA-Aufgaben" />
@ -55,8 +68,22 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="EinkaufwagenNummerJasminFehler" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.company.EinkaufwagenNummerJasminFehler" />
<module name="JAVA-Aufgaben" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.company.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.EinkaufwagenNummerJasminFehler" />
<item itemvalue="Application.EinkaufswagenNummer" />
</list>
</recent_temporary>
@ -70,6 +97,14 @@
<option name="presentableId" value="Default" />
<updated>1604858401120</updated>
</task>
<task id="LOCAL-00001" summary="EinkaufwagenNummer FERTIG">
<created>1604874532810</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1604874532810</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -77,46 +112,66 @@
<map>
<entry key="MAIN">
<value>
<State />
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="master" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="EinkaufwagenNummer FERTIG" />
<option name="LAST_COMMIT_MESSAGE" value="EinkaufwagenNummer FERTIG" />
</component>
<component name="WindowStateProjectService">
<state width="1877" height="186" key="GridCell.Tab.0.bottom" timestamp="1604874171771">
<state width="1877" height="348" key="GridCell.Tab.0.bottom" timestamp="1604907735664">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="348" key="GridCell.Tab.0.bottom/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907735664" />
<state width="1877" height="348" key="GridCell.Tab.0.center" timestamp="1604907735664">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="186" key="GridCell.Tab.0.bottom/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874171771" />
<state width="1877" height="186" key="GridCell.Tab.0.center" timestamp="1604874171771">
<state width="1877" height="348" key="GridCell.Tab.0.center/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907735664" />
<state width="1877" height="348" key="GridCell.Tab.0.left" timestamp="1604907735663">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="186" key="GridCell.Tab.0.center/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874171771" />
<state width="1877" height="186" key="GridCell.Tab.0.left" timestamp="1604874171771">
<state width="1877" height="348" key="GridCell.Tab.0.left/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907735663" />
<state width="1877" height="348" key="GridCell.Tab.0.right" timestamp="1604907735664">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="186" key="GridCell.Tab.0.left/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874171771" />
<state width="1877" height="186" key="GridCell.Tab.0.right" timestamp="1604874171771">
<state width="1877" height="348" key="GridCell.Tab.0.right/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907735664" />
<state width="1877" height="348" key="GridCell.Tab.1.bottom" timestamp="1604907739979">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="186" key="GridCell.Tab.0.right/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874171771" />
<state width="1877" height="348" key="GridCell.Tab.1.bottom" timestamp="1604874135045">
<state width="1877" height="348" key="GridCell.Tab.1.bottom/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.center" timestamp="1604907739979">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="348" key="GridCell.Tab.1.bottom/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874135045" />
<state width="1877" height="348" key="GridCell.Tab.1.center" timestamp="1604874135045">
<state width="1877" height="348" key="GridCell.Tab.1.center/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.left" timestamp="1604907739979">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="348" key="GridCell.Tab.1.center/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874135045" />
<state width="1877" height="348" key="GridCell.Tab.1.left" timestamp="1604874135045">
<state width="1877" height="348" key="GridCell.Tab.1.left/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.right" timestamp="1604907739979">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="348" key="GridCell.Tab.1.left/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874135045" />
<state width="1877" height="348" key="GridCell.Tab.1.right" timestamp="1604874135045">
<state width="1877" height="348" key="GridCell.Tab.1.right/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604907739979" />
<state x="552" y="252" key="Vcs.Push.Dialog.v2" timestamp="1604874536469">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="348" key="GridCell.Tab.1.right/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874135045" />
<state x="552" y="252" key="Vcs.Push.Dialog.v2/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604874536469" />
<state x="777" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1604858680692">
<screen x="0" y="0" width="1920" height="1040" />
</state>
@ -125,5 +180,20 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604861597120" />
<state x="682" y="431" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1604905992254">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="682" y="431" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604905992254" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/src/com/company/EinkaufswagenNummer.java</url>
<line>26</line>
<option name="timeStamp" value="5" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

@ -13,24 +13,24 @@ public class EinkaufswagenNummer {
wagenNummer = scanner.nextLine().replace("-", "");
}
boolean korrektheit = prüfungNummer(wagenNummer);
boolean korrektheit = pruefungNummer(wagenNummer);
ausgabe(korrektheit);
}
public static boolean prüfungNummer(String nummer){
public static boolean pruefungNummer(String nummer){
int gewichtung = 0;
for (int i = 0; i < nummer.length() - 1; i++) {
char cur = nummer.charAt(i);
gewichtung += Character.getNumericValue(cur) * (i % 2 == 0 ? 1 : 1);
char stelle = nummer.charAt(i);
gewichtung += Character.getNumericValue(stelle) * (i % 2 == 0 ? 1 : 1);
}
int PrüfziffEntfernen = nummer.charAt(nummer.length() - 1);
int PruefziffEntfernen = nummer.charAt(nummer.length() - 1);
int PrüfzifferBerechnet = Character.getNumericValue(PrüfziffEntfernen);
int prüfziffer = 10 - gewichtung % 10;
int pruefziffer = Character.getNumericValue(PruefziffEntfernen);
int PruefzifferBerechnet = 10 - gewichtung % 10;
boolean korrektheit = false;
if (PrüfzifferBerechnet != prüfziffer){
if (PruefzifferBerechnet != pruefziffer){
korrektheit = false;
} else {
korrektheit = true;

@ -0,0 +1,43 @@
package com.company;
import java.util.Scanner;
public class EinkaufwagenNummerJasminFehler {
public static void main(String[] args) {
//Einagbe der Kennnummer
try (Scanner scanner = new Scanner(System.in)) {
System.out.println("Bitte Kennnummer angeben: ");
String kennnummer = scanner.nextLine().replace("-", "");
//Überprüfen der Länge
if (kennnummer.length() != 4) {
System.out.print("Ungültige Länge!");
return;
}
//Gewichtung
int gewichtung = 0;
for (int i = 0; i < kennnummer.length() - 1; i++) {
char cur = kennnummer.charAt(i);
gewichtung += Character.getNumericValue(cur) * (i % 2 == 0 ? 1 : 1);
}
//Prüfziffer aus Kennnummer entfernen
int minusPrüfziffer = kennnummer.charAt(kennnummer.length() - 1);
//Die Prüfziffer der Kennnummer mit der fehlenden Prüfziffer berechnen
int kennnummerPrüfziffer = Character.getNumericValue(minusPrüfziffer);
int prüfziffer = 10 - gewichtung % 10;
//Ausgabe
if (kennnummerPrüfziffer != prüfziffer) {
System.out.println("Kennnummer ist nicht gültig!"+"Die Prüfziffer lautet:" + prüfziffer);
} else {
System.out.println("Kennnummer is korrekt!");
}
}
}
}
Loading…
Cancel
Save