Ich habe eine Methode zur multiplikation zweier zahlen geschrieben.. nur lässt diese sich leider nicht compilieren.. ich finde einfach keinen fehler... hier der code:
..........(error:33: missing return statement
}
^
..........
class DopHalbMet {
static int a, b;
public static int russianMultiplication(int a, int b) {
int x, y, c;
x = 0;
c = 1;
a = Integer.parseInt(JOptionPane.showInputDialog ("a = "));
b = Integer.parseInt(JOptionPane.showInputDialog ("b = "));
while ( b > 0)
{
if (b % 2 != 0) {
x = x + a;
a = a * 2;
b = b / 2; }
else
if (b % 2 == 0) {
a = a * 2;
b = b / 2; }
}
JOptionPane.showMessageDialog(null, " Das Produkt von a und b ist: " +x,
"Resultat", JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
public static void main (String[] args) {
russianMultiplication(a, b);
}
}