mercredi 27 avril 2016

c# if else statement

i am having a problem with an if-else statement (note: i am fairly inexperienced with programming) using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int number;

            Console.WriteLine("Please enter a number between 0 and 10:");
            number = int.Parse(Console.ReadLine());

            if(number > 10)
                Console.WriteLine("Hey! The number should be 10 or less!");
            else
                if(number < 0)
                    Console.WriteLine("Hey! The number should be 0 or more!");
                else
                    Console.WriteLine("Good job!");

            Console.ReadLine();
        }
    }
}

I use mono for compiling. i got these errors:

testif.txt(10,11): warning CS0642: Possible mistaken empty statement

testif.txt(13,9): error CS1525: Unexpected symbol `else'

Aucun commentaire:

Enregistrer un commentaire