Está en la página 1de 8

static void Main(string[] args)

{
//DECLARAMOS VARIABLES E IGUALAMOS A 0, TODO ENTERO
int num = 0;
int cont_num = 0, suma_po = 0;
int suma_neg = 0, prom_posi = 0, prom_total = 0;

//PEDIMOS INGRESAR UN NUMERO PARA NUESTRO CONTADOR FOR (NUMEROS)


Console.WriteLine("Cuantos numeros va ingresar");

//CONVERTIMOS EN ENTERO EL NUMERO INGRESADO QUE POR DEFECTO ES COMO SI FUERA


TEXTO
int numeros = int.Parse(Console.ReadLine());

//AHORA USAMOS NUESTRO NUMERO INGRESADO EN LA FUNCION (FOR)

for (int i = 1; i <= numeros; i++)


{
//AHORA REALIZAMOS LA OPERACIN QUE NOS PIDE CALCULAR EL PROMEDIO DE NUMEROS
//POSITIVOS, NEGATIVOS Y CONTAR CUANTOS NUMEROS FUERON MAYORES A 0
Console.WriteLine("Digite un numero: ");
num = int.Parse(Console.ReadLine());
//LUEGO DE HABER OBTENIDO NUESTRA VARIABLE (NUM) INGRESADO HACEMOS NUESTRA
CONDICIONAL SI ES MAYOR A 0 Y SON POSITIVOS;
if (num > 0)
{
//AQUI NUESTRA VARIABLE CONT_NUM NOS PERMITE CONTAR CUANTOS NUMEROS INGRESADOS
SUMANDOLE + 1
//AHORA PARA SUMAR LOS NUMEROS MAYORES A 0 QUE SON POSITIVOS A NUESTRA VARIABLE
SUMA_PO LE SUMAMOS EL NUMERO INGRESADO QUE ES (NUM)
cont_num = cont_num + 1;
suma_po = suma_po + num;
}
//PARA LA SUMA DE LOS NEGATIVOS HACEMOS NUESTRA CONDICIONAL A VER SI ES MENOR A
0 QUE SON NEGATIVOS, LE SUMAMOS (NUM)
if (num < 0)
{
suma_neg = suma_neg + num;
}

num = 0;
}
//AHORA FUERA DE LA FUNCION (FOR), LOGRAMOS REALIZAR NUESTROS PROMEDIOS.
prom_posi = suma_po / cont_num;
prom_total = (suma_po + suma_neg) / numeros;
//a)

Console.WriteLine("________________________________________________");
Console.WriteLine("Hay {0} numeros mayores a 0 ",cont_num);
//b)
Console.WriteLine(" El promedio de los numeros positivos son : "
+prom_posi);
Console.WriteLine(" El promedio total es: " +prom_total);
Console.ReadKey();
}
}
static void Main(string[] args)
{
int nota1 = 0, nota2 = 0, notafinal = 0, cod_prof = 0 ;
Console.WriteLine("Cuantos registros va ingresar");
int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{

Console.WriteLine("Ingrese nota 1: ");


nota1 = int.Parse(Console.ReadLine());
Console.WriteLine("Ingrese nota 2: ");
nota2 = int.Parse(Console.ReadLine());
Console.WriteLine("----------------------------------");
Console.WriteLine("Ingrese codigo del profesor");
Console.WriteLine("del 1 al 3");
cod_prof = int.Parse(Console.ReadLine());

if (cod_prof == 1)
{
notafinal = (nota1 + nota2) / 2;
Console.WriteLine("Su nota final es : " + notafinal);

}
if (cod_prof == 2)
{
notafinal = (nota1 + (nota2 * 2)) / 3;
Console.WriteLine("Su nota final es : " + notafinal);
}
if (cod_prof == 3)
{
notafinal = ((nota1 * 2) + nota2) / 3;
Console.WriteLine("Su nota final es : " + notafinal);
}

Console.ReadKey();
}
}
class Program
{
static void Main(string[] args)
{
int enfermedad = 0, edad = 0;
double pago=0;
Console.WriteLine("Cuantos registros va ingresar");
int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{
Console.WriteLine("*******************************");
Console.WriteLine("INGRESE SU EDAD: ");
edad = int.Parse(Console.ReadLine());

if ( edad > 14 && edad < 22)


{
Console.WriteLine("_______________________________");
Console.WriteLine("Ingrese tipo de enfermedad");
Console.WriteLine("tipo de enfermedad 1: ");
Console.WriteLine("tipo de enfermedad 2: ");
Console.WriteLine("tipo de enfermedad 3: ");
Console.WriteLine("tipo de enfermedad 4: ");
enfermedad = int.Parse(Console.ReadLine());
switch(enfermedad)
{
case 1:
pago = 25 + (25 * 0.10);
Console.WriteLine("DEBE PAGAR : "+pago);
break;
case 2:
pago = 16 + (16 * 0.10);
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 3:
pago = 20 + (20 * 0.10);
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 4:
pago = 32 + (32 * 0.10);
Console.WriteLine("DEBE PAGAR : " + pago);
break;
default:
Console.WriteLine("TIPO DE ENFERMEDAD ERRONEA");
break;
}

}
else
{
Console.WriteLine("_______________________________");
Console.WriteLine("Ingrese tipo de enfermedad");
Console.WriteLine("tipo de enfermedad 1: ");
Console.WriteLine("tipo de enfermedad 2: ");
Console.WriteLine("tipo de enfermedad 3: ");
Console.WriteLine("tipo de enfermedad 4: ");
enfermedad = int.Parse(Console.ReadLine());
switch (enfermedad)
{
case 1:
pago = 25;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 2:
pago = 16;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 3:
pago = 20;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 4:
pago = 32;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
default:
Console.WriteLine("TIPO DE ENFERMEDAD ERRONEA");
break;
}
}

Console.ReadKey();
}
}
//la 1

int enfermedad = 0;
string sexo;
double pago = 0;
Console.WriteLine("Cuantos registros va ingresar");
int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{
Console.WriteLine("*******************************");
Console.WriteLine("INGRESE SU SEXO: ");
Console.WriteLine("F:SI ES FEMENINO ");
Console.WriteLine("M:SI ES MASCULINO ");
sexo = Console.ReadLine();

if (sexo == "F" )
{
Console.WriteLine("_______________________________");
Console.WriteLine("Ingrese tipo de enfermedad");
Console.WriteLine("tipo de enfermedad 1: ");
Console.WriteLine("tipo de enfermedad 2: ");
Console.WriteLine("tipo de enfermedad 3: ");
enfermedad = int.Parse(Console.ReadLine());
switch (enfermedad)
{
case 1:
pago = 200 + (200 * 0.10);
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 2:
pago = 350;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 3:
pago = 420;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
default:
Console.WriteLine("TIPO DE ENFERMEDAD ERRONEA");
break;
}

}
if (sexo == "M")
{
Console.WriteLine("_______________________________");
Console.WriteLine("Ingrese tipo de enfermedad");
Console.WriteLine("tipo de enfermedad 1: ");
Console.WriteLine("tipo de enfermedad 2: ");
Console.WriteLine("tipo de enfermedad 3: ");
enfermedad = int.Parse(Console.ReadLine());
switch (enfermedad)
{
case 1:
pago = 200;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 2:
pago = 350;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
case 3:
pago = 420 + (420 * 0.05);;
Console.WriteLine("DEBE PAGAR : " + pago);
break;
default:
Console.WriteLine("TIPO DE ENFERMEDAD ERRONEA");
break;
}

Console.ReadKey();

//la 2

int cont_primos = 0, num = 0;


Console.WriteLine("Cuantos registros va ingresar");
int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{
Console.WriteLine("ingrese un numero");
num = int.Parse(Console.ReadLine());

if (num % i == 0)
{
cont_primos++;
Console.WriteLine("Si es Primo");
}
else
{
Console.WriteLine("No es Primo");
}
}

Console.WriteLine("{0} : son numeros primos", cont_primos);


Console.ReadKey();

//La 3

string nombre, primera, resto, lista = "";

Console.WriteLine("Cuantos socios va ingresar");


int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{

Console.WriteLine("INGRESE NOMBRE");
nombre = Console.ReadLine();

primera = nombre.Substring(0, 1);


primera = primera.ToUpper();
resto = nombre.Substring(1);
resto = resto.ToLower();
nombre = primera + resto;

lista += nombre + "\n ";

}
Console.WriteLine(" los socios son : " + lista);

Console.ReadKey();

int num = 0;
double raiz = 0;
Console.WriteLine("Cuantos numeros va ingresar");
int numeros = int.Parse(Console.ReadLine());

for (int i = 1; i <= numeros; i++)


{
Console.WriteLine("ingrese un numero");
num = int.Parse(Console.ReadLine());

raiz = Math.Sqrt(num);
raiz = raiz * 10;

if (raiz % 10 == 0)
{
Console.WriteLine("es un numero perfecto "+num);
}
else
{
Console.WriteLine("no es un numero perfecto " + num);
}
}
Console.ReadKey();

También podría gustarte