samedi 30 janvier 2021

Input Logic Not Resolving As Anticipated

I'm trying to figure out my code isn't working.

I'm trying to input an age, and assign a color to it based on it like I've show below, but my input always comes out green if its above 12.

Console.WriteLine("input your age: ");
int age = int.Parse(Console.ReadLine());

if (age<= 12)
{
    Console.WriteLine("color: white");
}
else if (age>= 13)
{
    Console.WriteLine("color: green");
}
else if (age >= 19)
{
    Console.WriteLine("color: red");
}
else if (age >= 26)
{
    Console.WriteLine("color: blue");
}
else
{
    Console.WriteLine("invalid age");
}

Console.ReadLine();

Aucun commentaire:

Enregistrer un commentaire