I am trying to write an If statement in C# where the user is asked to input the age, the program prints the age and if the user is eligible to cast the vote, where the age limit is 18.
When running the code in Visual Studio there are no errors, but on the platform where I am doing the exercise I have an error printed:
Incorrect output: your program printed "18", but should have printed "18"
It will be much appreciated if you could only point out the mistake (if any).
static void Main(string[] args)
{
int age;
Console.Write("Please input your age: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write(age);
Console.Write("\n");
if (age < 18)
{
Console.Write("You cannot cast your vote!");
}
else
Console.Write("You can cast your vote!");
{
}
}
Aucun commentaire:
Enregistrer un commentaire