Programm hängt sich auf

Seatdriver87

Mitglied
Hallo Leute,

brauch wieder mal Hilfe. Ich verstehe nicht warum sich mein Program aufhängt, wenn ich die Zahlen -5 und -5 eingebe. Hat jm ne Ahnung?

Java:
import java.io.*;
class multiplikation
{
public static void main (String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
String input;

int multiplikant;
System.out.println("Geben Sie eine ganze Zahl, den Multiplikanten ein:");
input = stdin.readLine();
multiplikant = Integer.parseInt( input ); 

int multiplikator;
System.out.println("Geben Sie eine ganze Zahl, den Multiplikator ein:");
input = stdin.readLine();
multiplikator = Integer.parseInt( input ); 

int a = multiplikant, b = multiplikator, c = 0; 

do {
         c = c + a;
         b = b - 1;  { }
       } while (b > 0);
       
if (b < 0) { 
     do {
         c = c + a;
         a = b + 1;  { }
       } while (b < 0);
   }  {
System.out.println( "Das Ergebnis von " + multiplikant + " x " + multiplikator + " = " + c );
}
}
}
 

Zurück
Oben