2do Parcial C#
2do Parcial C#
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace P.O.O_ejercicios_para_2do_parcial
{
internal class Program
{
static void Main(string[] args)
{
//REGISTRAR LA COMPRAS DE COMIDA RAPIDA
{
byte hamburguesa, Lomitos, pollos, refresco;
double pagar;
int a, b;
long resultado;
Console.WriteLine("INTRODUZCA UN NUMERO");
a = int.Parse(Console.ReadLine());
resultado = Math.Abs(a);
Console.WriteLine("EL VALOR ABSOLUTO ES: " + resultado);
Console.WriteLine(" ");
}
//ejercicio 3
{
double Base, altura, resultado;
Console.WriteLine(" ");
}
//ejercicio 4
{
int a, b;
Console.WriteLine("verificar quien es mayor");
Console.WriteLine("introduzca el primer numero");
a = int.Parse(Console.ReadLine());
Console.WriteLine("introduzca el segundo numero");
b = int.Parse(Console.ReadLine());
if (a > b)
{
Console.WriteLine("{0} es mayor {1}", a, b);
}
else if (b > a)
{
Console.WriteLine("{0} es menor {1}", a, b);
}
else { Console.WriteLine("{0} es igual {1}", a, b); }
}
//ejercicio 5
{
Console.WriteLine("EL MAYOR DE TRES NUMEROS");
int A, B, C, mayor, menor;
Console.WriteLine("INTRODUZCA EL PRIMER VALOR");
A = int.Parse(Console.ReadLine());
Console.WriteLine("INTRODUZCA EL SEGUNDO VALOR");
B = int.Parse(Console.ReadLine());
Console.WriteLine("INTRODUZCA EL TERCER VALOR");
C = int.Parse(Console.ReadLine());
mayor = A; menor = A;
if (B > mayor) mayor = B;
if (C > mayor) mayor = C;
//EJERCICIO 6
{
Console.WriteLine("HALLAR EL NUMERO INTERMEDIO DE TRES NUMEROS");
while (1 + 1 == 2)
{
int A, B, C;
Console.WriteLine("INTRODUZCA EL PRIMER VALOR");
A = int.Parse(Console.ReadLine());
Console.WriteLine("INTRODUZCA EL SEGUNDO VALOR");
B = int.Parse(Console.ReadLine());
Console.WriteLine("INTRODUZCA EL TERCER VALOR");
C = int.Parse(Console.ReadLine());
//A=100
//B=50
//C=10
if (((A > B) && (A < C)) || ((A < B) && (A > C)))
{
Console.WriteLine("EL NUMERO INTERMEDIO ES: " + A);
}
else
{
if (((B > A) && (B < C)) || ((B < A) && (B > C)))
}
}
}
//EJERCICIO 7
{
int A, B, C;
while (1 + 1 == 2)
{
Console.WriteLine("HALLAR LOS LADOS DE LOS TRIANGULOS");
Console.WriteLine("Digite el primer valor de los lados");
A = int.Parse(Console.ReadLine());
Console.WriteLine("Digite el segundo valor de los lados");
B = int.Parse(Console.ReadLine());
Console.WriteLine("digite el tercer valor de los lados");
C = int.Parse(Console.ReadLine());
char Ecivil;
string linea;
Console.WriteLine("Digite C,V,D,S, Dependiendo su estado civil");
linea = Console.ReadLine();
Ecivil = char.Parse(linea);
switch (Ecivil)
{
case 'C':
; Console.WriteLine("CASADO");
break;
case 'S':
; Console.WriteLine("SOLTERO");
break;
case 'V':
; Console.WriteLine("VIUDO");
break;
case 'D':
; Console.WriteLine("DIVORCIADO");
break;
}
Console.WriteLine(" ");
}
//EJERCICIO 9
{
//tabla de multiplicar
byte a;
int resultado;
Console.WriteLine("DIGITE UN NUMERO");
a = Byte.Parse(Console.ReadLine());
for (int i = 1; i <= 12; i++)
{
resultado = a * i;
Console.WriteLine("{0} * {1} = {2}", a, i, resultado);
}
//ejercicio 10
{
//suma de pares y impares
byte a;
int sumI = 0;
int sumaP = 0;
Console.WriteLine("digite un numero");
a= Byte.Parse(Console.ReadLine());
Console.WriteLine("-------Impares---------");
for (int x = 1; x <= a; x=x +2)
{
Console.WriteLine(x);
sumI = sumI + x;
}
Console.WriteLine("-------pares---------");
for (int j= 2; j <=a; j=j+2)
{
Console.WriteLine(j);
sumaP=sumaP + j;
}
Console.WriteLine("EL TOTAL DE PARES = "+sumaP);
}
Console.ReadKey();
}
}