jeudi 26 octobre 2017

C# if statement comparing Numbers

I'm really new to programming and have to write a little programming which tests if a number is smaller or bigger than 500, 2000 and 5000. Now I wrote this but it always takes the first else statement even if the number is bigger than 5000 it says the number is smaller than 500. Anybody knows why? Appreciate every help I get. :)

Here's the code:

double rebe, fuenfh = 500.00, zweit = 2000.00, fuenft = 5000.00;
    //zweiPro = 2.00, fuenfPro = 5.00, zehnPro = 10.00;

Console.WriteLine("How big is the number? Wie groß war Ihr Rechnungsbetrag? ");
rebe = Console.Read();

if (rebe >= fuenfh)
{
    if (rebe >= zweit)
    {
        if (rebe >= fuenft)
        {
            Console.WriteLine("bigger or same as 5000");
            Console.ReadLine();
            Console.Read();
        }

        else
        {
            Console.WriteLine("bigger or same as 2000 but smaller than 5000 // Groesser gleich als 2000 aber kleiner als 5000");
            Console.ReadLine();
            Console.Read();
        }
    }

    else
    {
        Console.WriteLine("bigger or same as 500 but smaller than 2000 // Groesser gleich 500 aber kleiner als 2000");
        Console.ReadLine();
        Console.Read();
    }
}
else
{
    Console.WriteLine("smaller than 500 // Leider gibt es keinen Rabatt. :(");
    Console.ReadLine();
    Console.Read();
}

Aucun commentaire:

Enregistrer un commentaire