dimanche 6 janvier 2019

Why does the else statement still run when an if statement before runs?

When "wunschnote" isn't > 6 and < 1 so that none of the if statements runs it works, but as soon as one of the if stamemts runs, the else stamements also executes...

I tried to set the "Console.ReadLine();" inside of the if statements, but that leads to the same problem. Then I tried to make replace the else statement into a if statement, but that also leads to the same problem.

if (wunschnote > 6)
{
    Console.WriteLine("Der Wunschnitt kann nicht erreicht werden.\nDie Wunschnote müsste eine " + wunschnote + " betragen.");
}

if (wunschnote < 1)
{
    Console.WriteLine("Der Wunschnitt kann nicht erreicht werden.\nDie Wunschnote müsste eine " + wunschnote + " betragen.");
}

else
{
    Console.WriteLine("In der nächsten Probe muss eine " + wunschnote + " erreicht werden, damit der Schnitt von " + wunsschnitt + " erreicht wird.");
}
Console.ReadLine();

I expect that when one of the if statements runs, the else statement won't get executet.

Aucun commentaire:

Enregistrer un commentaire