1
Otros / Mi operador "mod" no me reconoce números divisibles por 3. :(
« en: Abril 13, 2015, 05:39:51 pm »
Hola no entiendo qué puede estar fallando. Es una lástima que códigos tan simples, inclusive, me causan errores. u.u
Adjunto el código, espero que alguien me pueda decir pronto en qué falla y cómo corregirlo:
Adjunto el código, espero que alguien me pueda decir pronto en qué falla y cómo corregirlo:
Código: C
- class Program
- {
- static void Main(string[] args)
- {
- string textLine="";
- double num = 0;
- int i=0;
- //VERIFICA QUE SE INGRESE UN NÚMERO*************
- do{
- titulo();
- Console.Write("Hola usuario anónimo. Ingrese un número: ");
- textLine = Console.ReadLine();
- if (double.TryParse(textLine, out num) == false)
- {
- Console.WriteLine("Lo siento, ¿le dije que debía ser un número??");
- Console.ReadKey();
- Console.Clear();
- }
- }while(double.TryParse(textLine, out num) == false);
- //**********************************************
- //VERIFICA SI ES POSITIVO_____________________________
- if (num >= 0)
- {
- Console.WriteLine("\nEl número ingresado es positivo.");
- }
- else
- {
- Console.WriteLine("\nEl número ingresado es negativo.");
- }//___________________________________________________
- //VERIFICA SI ES DIVISIBLE POR 3______________________
- if (num % 3 == 0)
- {
- Console.WriteLine("Y divisible por 3.");
- }
- else
- {
- Console.WriteLine("Y no divisible por 3.");
- }
- Console.ReadKey();
- }
- public static void titulo()
- {
- Console.WriteLine("VALIDADOR DE NÚMERO A POSITIVO DIVISIBLE POR 3");
- Console.WriteLine("**********************************************");
- Console.WriteLine();
- }
- }