Schülerforum


Themen-übersicht  |  Suche
 Java ISBN Prüfziffer!
Autor:
 jie
Datum:
 27.09.2014 06:12
Fach:
 Informatik

Hallo zusammen,

nun habe ich schon die erste schwierige Aufgabe bekommen. Die Aufgabe lautet die ISBN zu verifizieren und anschliessend die Prüfziffer zu berechnen. Ich weiss wie man die Prüfziffer berechnet, aber weiss wirklich nicht, wie man das in java programmiert. Ich habs einmal probiert, kann mir jemand sagen, was ich genau falsch mache? Es will einfach nicht funktionieren... =( Hab jetzt nicht den ganzen Code reinkopiert nur den Prüfzifferteil! Zuerst definiere ich das Objekt und anschliessend wird die ISBN mit der Formel berechnet und danach durch modulo 11 geteilt. Vielen Dank für eure Hilfe!!!!!

//input isbn
String input= "123456789";
int d1 = Integer.parseInt(input.substring(1));
int d2 = Integer.parseInt(input.substring(2));
int d3 = Integer.parseInt(input.substring(3));
int d4 = Integer.parseInt(input.substring(4));
int d5 = Integer.parseInt(input.substring(5));
int d6 = Integer.parseInt(input.substring(6));
int d7 = Integer.parseInt(input.substring(7));
int d8 = Integer.parseInt(input.substring(8));
int d9 = Integer.parseInt(input.substring(9));




private static int d(){
int d1 = input.nextInt();
int d2 = input.nextInt();
int d3 = input.nextInt();
int d4 = input.nextInt();
int d5 = input.nextInt();
int d6 = input.nextInt();
int d7 = input.nextInt();
int d8 = input.nextInt();
int d9 = input.nextInt();
int d10 = ((d1*1) + (d2*2) + (d3*3) + (d4*4) + (d5*5) + (d6*6) + (d7*7) + d7*7 + (d8*8) + (d9*9)) % 11;

}


if (d10% = 10){
System.out.println ("ISBN is: " + d1+ d2+ d3+ d4+ d5+ d6 + d7 + d8 + d9 + d10);
}
else if (d10 == 10){
System.out.println ("ISBN is: " + d1 + d2 + d3 + d4 + d5 + d6 + d7+ d8 + d9 + d10);



}

 Re: Java ISBN Prüfziffer!
Autor:
 Chittra
Datum:
 22.08.2015 12:28
Fach:
 Informatik

Hello admin,(*) is used to import all clsseas and directories. right? but since here we have used only scanner class . So can we writeimport java.util.scanner; instead of import java.util.*;or there would be any error????


Kostenlos Informatik online lernen