BundeswehrPrüfnummer FERTIG

master
BuildTools 4 years ago
parent 0cf82937cc
commit 07b81120d8

@ -25,9 +25,10 @@
</select>
</component>
<component name="ChangeListManager">
<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" />
<list default="true" id="86f42963-ed9f-4d18-9c81-a4cf18fa27c4" name="Default Changelist" comment="+Jasmins Version EinkaufwagenNummer">
<change afterPath="$PROJECT_DIR$/src/com/company/BundeswehrPruefnummern.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/JAVA-Aufgaben/com/company/EinkaufswagenNummer.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/JAVA-Aufgaben/com/company/EinkaufswagenNummer.class" 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" />
@ -54,7 +55,20 @@
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
</component>
<component name="RunManager" selected="Application.EinkaufwagenNummerJasminFehler">
<component name="RunManager" selected="Application.BundeswehrPruefnummern">
<configuration name="BundeswehrPruefnummern" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.company.BundeswehrPruefnummern" />
<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>
<configuration name="EinkaufswagenNummer" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.company.EinkaufswagenNummer" />
<module name="JAVA-Aufgaben" />
@ -83,8 +97,9 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.EinkaufwagenNummerJasminFehler" />
<item itemvalue="Application.BundeswehrPruefnummern" />
<item itemvalue="Application.EinkaufswagenNummer" />
<item itemvalue="Application.EinkaufwagenNummerJasminFehler" />
</list>
</recent_temporary>
</component>
@ -104,7 +119,21 @@
<option name="project" value="LOCAL" />
<updated>1604874532810</updated>
</task>
<option name="localTasksCounter" value="2" />
<task id="LOCAL-00002" summary="+Jasmins Version EinkaufwagenNummer">
<created>1604908336396</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1604908336396</updated>
</task>
<task id="LOCAL-00003" summary="+Jasmins Version EinkaufwagenNummer">
<created>1604908350915</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1604908350915</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -133,45 +162,50 @@
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="EinkaufwagenNummer FERTIG" />
<option name="LAST_COMMIT_MESSAGE" value="EinkaufwagenNummer FERTIG" />
<MESSAGE value="+Jasmins Version EinkaufwagenNummer" />
<option name="LAST_COMMIT_MESSAGE" value="+Jasmins Version EinkaufwagenNummer" />
</component>
<component name="WindowStateProjectService">
<state width="1877" height="348" key="GridCell.Tab.0.bottom" timestamp="1604907735664">
<state width="1877" height="186" key="GridCell.Tab.0.bottom" timestamp="1605033112583">
<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">
<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="1605033112583" />
<state width="1877" height="186" key="GridCell.Tab.0.center" timestamp="1605033112583">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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">
<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="1605033112583" />
<state width="1877" height="186" key="GridCell.Tab.0.left" timestamp="1605033112583">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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">
<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="1605033112583" />
<state width="1877" height="186" key="GridCell.Tab.0.right" timestamp="1605033112583">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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">
<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="1605033112583" />
<state width="1877" height="262" key="GridCell.Tab.1.bottom" timestamp="1605022562079">
<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="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.center" timestamp="1604907739979">
<state width="1877" height="262" key="GridCell.Tab.1.bottom/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1605022562079" />
<state width="1877" height="262" key="GridCell.Tab.1.center" timestamp="1605022562079">
<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="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.left" timestamp="1604907739979">
<state width="1877" height="262" key="GridCell.Tab.1.center/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1605022562079" />
<state width="1877" height="262" key="GridCell.Tab.1.left" timestamp="1605022562079">
<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="1604907739979" />
<state width="1877" height="348" key="GridCell.Tab.1.right" timestamp="1604907739979">
<state width="1877" height="262" key="GridCell.Tab.1.left/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1605022562079" />
<state width="1877" height="262" key="GridCell.Tab.1.right" timestamp="1605022562079">
<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="1604907739979" />
<state x="552" y="252" key="Vcs.Push.Dialog.v2" timestamp="1604874536469">
<state width="1877" height="262" key="GridCell.Tab.1.right/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1605022562079" />
<state x="686" y="240" key="RollbackChangesDialog" timestamp="1605007609774">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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="686" y="240" key="RollbackChangesDialog/3840.0.1920.1040/1920.0.1920.1040/0.0.1920.1040@0.0.1920.1040" timestamp="1605007609774" />
<state x="552" y="252" key="Vcs.Push.Dialog.v2" timestamp="1604908396517">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<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="1604908396517" />
<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>
@ -185,15 +219,4 @@
</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>

@ -0,0 +1,79 @@
package com.company;
import java.util.Scanner;
public class BundeswehrPruefnummern {
public static void main(String[] args){
Eingabe();
}
public static void Eingabe(){
Scanner scanner = new Scanner(System.in);
System.out.println("Bitte geben sie die Personennummer ein: ");
String personennummer = scanner.nextLine().replace("-", "");
////Überprüfung der länge
while (personennummer.length() != 11 && personennummer.substring(5, 6) != "[A, B, C, D-Z]") {
System.out.println("Die Nummer muss 11 Stellen lang sein oder dem Syntax entsprechen. Bitte erneut eingeben");
personennummer = scanner.nextLine().replace("-", "");
}
String[] eingabe = new String[11];
for(int g = 0; g < 11; g++){
eingabe[g] = personennummer.substring(g, (g+1));
}
int prueziffer = Algorithmus(eingabe);
Ausgabe(prueziffer);
}
public static int Algorithmus(String Eingabe[]){
String[] geburtsname = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
String[] geburtsnameValue = {"12", "14", "16", "18", "20", "22", "24", "26", "28", "6", "8", "10", "12", "14", "16", "18", "20", "22", "4", "6", "8", "10", "12", "14", "16", "18"};
int[] gewichtung = {2, 3, 4, 5, 6, 7, 1, 6, 7, 2, 3};
//// Umwandlung des Buchstabens in eine Zahl
for(int i = 0; i < 26; i++ ){
if(Eingabe[6].equals(geburtsname[i])){
Eingabe[6] = geburtsnameValue[i];
}
}
int[] INTeingabe = new int[11];
for(int i = 0;i < Eingabe.length;i++)
{
INTeingabe[i] = Integer.parseInt(Eingabe[i]);
}
//// Gewichtung und Summierung
int summe = 0;
int[] nummern = new int[11];
for (int j = 0; j < 11; j++){
nummern[j] = INTeingabe[j]*gewichtung[j];
summe = summe+nummern[j];
}
//// Ermittlung der Prüfnummer
int prueziffer = 0;
int mod = summe%11;
int Differenz = 11-mod;
if(Differenz == 10){
return(prueziffer);
}else if(Differenz == 11){
prueziffer = 1;
}else{
prueziffer = mod;
}
////
return(prueziffer);
}
public static void Ausgabe(int p){
Scanner scanner = new Scanner(System.in);
System.out.println("Die Prüfziffer lautet: "+p);
System.out.println("Wollen Sie eine weitere Personennummer pruefen? Wenn ja bitte mit y bestätigen. Wenn nich kann das Programm mit n beendet werden.");
String weiter = scanner.nextLine().replace("-", "");
if(weiter.equals("y")) {
Eingabe();
}
}
}

@ -3,13 +3,18 @@ import java.util.Scanner;
public class EinkaufswagenNummer {
public static void main(String[] args){
public static void main(String[] args) {
Eingabe();
}
public static void Eingabe(){
Scanner scanner = new Scanner(System.in);
System.out.println("Bitte geben sie die Kennnummer ein: ");
String wagenNummer = scanner.nextLine().replace("-", "");
while (wagenNummer.length() != 4 ){
System.out.println("Die Nummer muss 4 Stellen lang sein. Bitte erneut eingeben");
while (wagenNummer.length() != 4) {
System.out.println("Die Nummer muss 4 Stellen lang sein. Bitte erneut eingeben");
wagenNummer = scanner.nextLine().replace("-", "");
}
@ -40,10 +45,17 @@ public class EinkaufswagenNummer {
}
public static void ausgabe(boolean korrektheit){
Scanner scanner = new Scanner(System.in);
if (korrektheit != true) {
System.out.println("Die Kennnummer ist nicht korrekt oder ungültig!");
} else {
System.out.println("Kennnummer is gültig!");
}
System.out.println("Wollen Sie eine weitere Nummer pruefen? Wenn ja bitte mit Y bestätigen. Wenn nich kann das Programm mit N beendet werden.");
String weiter = scanner.nextLine().replace("-", "");
if(weiter.equals("Y")) {
Eingabe();
}
}
}

Loading…
Cancel
Save