public void ex1() { Console.WriteLine("Exercicio 1 - Qual é a pessoa mais velha?"); Exercicio1 pessoaUm = new Exercicio1(); Exercicio1 pessoaDois = new Exercicio1(); Console.Write("Digite o nome da primeira pessoa: "); pessoaUm.nome = (Console.ReadLine()); // Console.WriteLine(""); Console.Write("Digite a idade da primeira pessoa: "); pessoaUm.idade = int.Parse(Console.ReadLine()); Console.WriteLine("----------------------------------"); Console.Write("Digite o nome da segunda pessoa: "); pessoaDois.nome = (Console.ReadLine()); // Console.WriteLine(""); Console.Write("Digite a idade da segunda pessoa: "); pessoaDois.idade = int.Parse(Console.ReadLine()); Console.WriteLine(""); if (pessoaUm.idade > pessoaDois.idade) { Console.WriteLine("Pessoa mais velha: " + pessoaUm.nome); Console.WriteLine("Pressione a tecla Enter para sair..."); Console.ReadKey(); } else { Console.WriteLine("Pessoa mais velha: " + pessoaDois.nome); Console.WriteLine("Pressione a tecla Enter para sair..."); Console.ReadKey(); } }
static void Main(string[] args) { Exercicio1.Executar(); Exercicio2.Executar(); Exercicio3.Executar(); Exercicio4.Executar(); Exercicio5.Executar(); Exercicio6.Executar(); }
public void VerificaMenorDiferençaEntreNumerosTest() { Exercicio1 ex = new Exercicio1(); List <int> lsNumeros1; List <int> lsNumeros2; lsNumeros1 = new List <int>() { 1, 3, 15, 11, 2 }; lsNumeros2 = new List <int>() { 23, 127, 235, 19, 8 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumeros(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 3, 15, 12, 2 }; lsNumeros2 = new List <int>() { 23, 127, 235, 19, 8 }; Assert.IsFalse(ex.VerificaMenorDiferençaEntreNumeros(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 3, 15, 11, 2, 20 }; lsNumeros2 = new List <int>() { 23, 127, 235, 19, 8 }; Assert.IsFalse(ex.VerificaMenorDiferençaEntreNumeros(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 3, 15, 11, 2, 20 }; lsNumeros2 = new List <int>() { 23, 127, 235, 19, 8 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumeros(lsNumeros1, lsNumeros2) == 1); lsNumeros1 = new List <int>() { 1, 3, 15, 11, 2, 20 }; lsNumeros2 = new List <int>(); Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumeros(lsNumeros1, lsNumeros2) == -1); }
public ActionResult Exercicio1Result(Exercicio1 model) { string cnpj = ""; try { if (ModelState.IsValid) { TempData["msgSuccess"] = "O CNPJ " + model.CNPJ + " foi validado com sucesso"; } else { TempData["msgFalha"] = "Favor Verificar o preenchimento"; } } catch { TempData["msgFalha"] = "Ocorreu um erro, favor entrar em contato com o administrador"; } return(View("Exercicio1", model)); }
public void VerificaMenorDiferençaEntreNumerosListaOrdenadaTest() { Exercicio1 ex = new Exercicio1(); List <int> lsNumeros1; List <int> lsNumeros2; lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 2, 3, 12, 15 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsFalse(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsFalse(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 3); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 1); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; lsNumeros2 = new List <int>() { }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == -1); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; lsNumeros2 = new List <int>() { 100 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 80); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, null) == -1); Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(null, null) == -1); lsNumeros1 = new List <int>() { 1, 2, 3, 11, 15, 20 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 1); lsNumeros1 = new List <int>() { 1, 2, 3, 5 }; lsNumeros2 = new List <int>() { 18, 19, 23, 127, 235 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 13); lsNumeros1 = new List <int>() { 10, 11, 15, 25 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127, 235 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 2); lsNumeros1 = new List <int>() { 200, 321 }; lsNumeros2 = new List <int>() { 8, 19, 23, 127 }; Assert.IsTrue(ex.VerificaMenorDiferençaEntreNumerosListaOrdenada(lsNumeros1, lsNumeros2) == 73); }
static void Main(string[] args) { Exercicio1.Executar(); }