EinkaufwagenNummer FERTIG

master
BuildTools 4 years ago
parent 514ae55a0e
commit 60dd113db4

@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectKey"> <component name="ProjectRootManager" version="2" project-jdk-name="openjdk-15" project-jdk-type="JavaSDK">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" default="true" project-jdk-name="14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

@ -6,11 +6,24 @@
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" /> <item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" /> <item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path> </path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand> </expand>
<select /> <select />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="44e8584f-f728-47f9-a7ad-f3016b17c485" name="Default Changelist" comment="test" /> <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" />
<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>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -18,48 +31,45 @@
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component> </component>
<component name="ProjectId" id="1k1BTGZOv3foDGM203RaTLvxY72" /> <component name="ProjectId" id="1k1BpdfEvGNnSx2c1X5bJxpMHhA" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true"> <configuration name="EinkaufswagenNummer" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.company.Main" /> <option name="MAIN_CLASS_NAME" value="com.company.EinkaufswagenNummer" />
<module name="JAVA-Aufgaben" /> <module name="JAVA-Aufgaben" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <extension name="coverage">
<RunnerSettings RunnerId="Run" /> <pattern>
<ConfigurationWrapper RunnerId="Run" /> <option name="PATTERN" value="com.company.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
</configuration> </configuration>
<recent_temporary>
<list>
<item itemvalue="Application.EinkaufswagenNummer" />
</list>
</recent_temporary>
</component> </component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
<changelist id="44e8584f-f728-47f9-a7ad-f3016b17c485" name="Default Changelist" comment="" /> <changelist id="86f42963-ed9f-4d18-9c81-a4cf18fa27c4" name="Default Changelist" comment="" />
<created>1604858224360</created> <created>1604858401120</created>
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1604858224360</updated> <updated>1604858401120</updated>
</task> </task>
<task id="LOCAL-00001" summary="test">
<created>1604858298513</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1604858298513</updated>
</task>
<task id="LOCAL-00002" summary="ttest">
<created>1604858461951</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1604858461951</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -72,16 +82,48 @@
</entry> </entry>
</map> </map>
</option> </option>
</component> <option name="oldMeFiltersMigrated" value="true" />
<component name="VcsManagerConfiguration">
<MESSAGE value="test" />
<MESSAGE value="ttest" />
<option name="LAST_COMMIT_MESSAGE" value="ttest" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="552" y="253" key="Vcs.Push.Dialog.v2" timestamp="1604858471295"> <state width="1877" height="186" key="GridCell.Tab.0.bottom" timestamp="1604874171771">
<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">
<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">
<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">
<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">
<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">
<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">
<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">
<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="777" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1604858680692">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="777" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1604858680692" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1604861597120">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="552" y="253" key="Vcs.Push.Dialog.v2/0.0.1920.1040@0.0.1920.1040" timestamp="1604858471295" /> <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" />
</component> </component>
</project> </project>

@ -5,36 +5,45 @@ public class EinkaufswagenNummer {
public static void main(String[] args){ public static void main(String[] args){
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
String wagenNummer = scanner.next(); System.out.println("Bitte geben sie die Kennnummer ein: ");
String wagenNummer = scanner.nextLine().replace("-", "");
while (wagenNummer.length() == 4 ){ while (wagenNummer.length() != 4 ){
System.out.println("Die Nummer muss 4 Stellen lang sein. Bitte erneut eingeben");
if(wagenNummer.length() == 4){ wagenNummer = scanner.nextLine().replace("-", "");
prüfungNummer();
ausgabe();
}
else{
System.out.println("Nummer zu kurz. Bitte erneut eingeben");
wagenNummer = scanner.next();
}
} }
boolean korrektheit = prüfungNummer(wagenNummer);
ausgabe(korrektheit);
}
public static boolean prüfungNummer(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);
} }
public static int prüfungNummer(){ int PrüfziffEntfernen = nummer.charAt(nummer.length() - 1);
int test = 1;
int PrüfzifferBerechnet = Character.getNumericValue(PrüfziffEntfernen);
int prüfziffer = 10 - gewichtung % 10;
return(test); boolean korrektheit = false;
if (PrüfzifferBerechnet != prüfziffer){
korrektheit = false;
} else {
korrektheit = true;
} }
public static String ausgabe(){ return(korrektheit);
String test2 = "test"; }
return(test2); public static void ausgabe(boolean korrektheit){
if (korrektheit != true) {
System.out.println("Die Kennnummer ist nicht korrekt oder ungültig!");
} else {
System.out.println("Kennnummer is gültig!");
}
} }
} }

Loading…
Cancel
Save