This code should return area and perimeter with the radio, that, does it, though will should addition the odd numbers when the radio is odd, but it does the opposite.
//int radio;
float radio, area, perimetro, PI = 3.1416f;
string texto;
//float constante = 3.1416f;
Console.Write("Ingrese Radio del Circulo: ");
texto = Console.ReadLine();
radio = int.Parse(texto);
area = PI * radio * radio;
perimetro = 2 * PI * radio;
Console.WriteLine("\nEl area del circulo es: " + area);
Console.WriteLine("El Perimetro del circulo es: " + perimetro);
if ((radio % 2) == 0)
{
Console.WriteLine("\nSuma Impares: " + (radio + area + perimetro));
}
else
{
Console.WriteLine("\nEl Radio es Par");
}
Console.WriteLine("\nPresione Cualquier tecla para finalizar");
Console.ReadKey();
}
}
}
Aucun commentaire:
Enregistrer un commentaire