0% encontró este documento útil (0 votos)
10 vistas5 páginas

2do Parcial C#

Cargado por

fazambrana-es
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como DOCX, PDF, TXT o lee en línea desde Scribd
0% encontró este documento útil (0 votos)
10 vistas5 páginas

2do Parcial C#

Cargado por

fazambrana-es
Derechos de autor
© © All Rights Reserved
Nos tomamos en serio los derechos de los contenidos. Si sospechas que se trata de tu contenido, reclámalo aquí.
Formatos disponibles
Descarga como DOCX, PDF, TXT o lee en línea desde Scribd
Está en la página 1/ 5

using System;

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;

const int precioH = 10;


const int precioL = 15;
const int precioR = 3;
const int precioP = 10;

Console.WriteLine("CUANTOS HAMBURGUESA DESEA");


hamburguesa = byte.Parse(Console.ReadLine());
Console.WriteLine("CUANTOS LOMITOS DESEA");
Lomitos = byte.Parse(Console.ReadLine());
Console.WriteLine("CUANTOS POLLOS DESEA");
pollos = byte.Parse(Console.ReadLine());
Console.WriteLine("CUANTOS REFRESCO DESEA");
refresco = byte.Parse(Console.ReadLine());

pagar = (hamburguesa * precioH) + (Lomitos * precioL) + (pollos * precioP) + (refresco *


precioR);

Console.WriteLine("COSTO A PAGAR ES: " + pagar + " bs.");


Console.WriteLine(" ");
}
//EJERCICIO 2
{

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("QUE NUMERO DESEA CONVERTIR A POTENCIA:");


b = int.Parse(Console.ReadLine());
Console.WriteLine("EL VALOR DE LA POTENCIA ES: " + (Math.Pow(a, b)));
Console.WriteLine("EL VALOR DE RAIZ CUADRADA ES: " + Math.Sqrt(a));
Console.WriteLine("SENO " + Math.Sin(a * Math.PI / 180));
Console.WriteLine("MAXIMO " + Math.Max(a, 50));
Console.WriteLine("PARTE ENTERA DEL NUMERO: " + Math.Truncate(18.78));
Console.WriteLine("REDONDEO: " + Math.Round(19.52));

Console.WriteLine(" ");
}
//ejercicio 3
{
double Base, altura, resultado;

Console.WriteLine("SACAR EL AREA DE UN TRIANGULO");


Console.WriteLine("INTRODUZCA LA BASE");
Base = double.Parse(Console.ReadLine());
Console.WriteLine("INTRODUZCA LA ALTURA");
altura = double.Parse(Console.ReadLine());

resultado = (Base * altura / 2);

Console.WriteLine("EL AREA DEL TRIANGULO ES: " + String.Format("{0:####.00}",


resultado));
Console.WriteLine("EL AREA DEL TRIANGULO ES: " + String.Format("{0:F}", resultado));
Console.WriteLine("HOY ES: " + String.Format("{0:F}", DateTime.Now));
Console.WriteLine("HOY ES: " + String.Format("{0:dddd} {0:dd/MM/yyyy}", DateTime.Now));
Console.ReadKey();

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;

if (B < menor) menor = B;


if (C < menor) menor = C;
Console.WriteLine("EL NUMERO MAYOR ES: " + mayor);

//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)))

Console.WriteLine("EL NUMERO INTERMEDIO ES: " + B);


else
{
if (((C > A) && (C < B)) || ((C < A) && (C > B)))
Console.WriteLine("EL NUMERO INTERMEDIO ES: " + 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());

if ((A == B) && (A == C))


{
Console.WriteLine("TRIÁNGULO EQUILÁTERO. TODOS LOS LADOS SON IGUALES");
}
else if ((A != B) && (A != C) && (B != C))
{
Console.WriteLine("TRIANGULO ESCALENO, NINGUNO ES IGUAL");
}
else { Console.WriteLine("TRIANGULO ISOCELES, DOS LADOS SON IGUALES"); }
Console.WriteLine(" ");
}
}
// EJERCICIO 8
{
//ESTADO CIVIL

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.WriteLine("EL TOTAL DE IMPARES = "+sumI);

}
Console.ReadKey();

}
}

También podría gustarte