Exemplo n.º 1
0
        public void btnConfirmar_Click(object sender, EventArgs e)
        {
            String TextoN1;
            String TextoN2;
            int    N1;
            int    N2;
            int    Resultado;
            int    Resultado2;

            TextoN1 = txtDias.Text;
            TextoN2 = txtHora.Text;
            N1      = Convert.ToInt32(txtDias.Text);
            N2      = Convert.ToInt32(txtHora.Text);

            Resultado  = N2 * 8;
            Resultado2 = Resultado * N1;

            txtTotal_Inicial.Text = Resultado2.ToString();
        }
Exemplo n.º 2
0
        public void btnsueldo_Click(object sender, EventArgs e)
        {
            string txtN1;
            string txtN2;
            int    N1;
            int    N2;
            int    Resultado;
            int    Resultado2;

            txtN1 = txtdias.Text;
            txtN2 = txthora.Text;

            N1 = Convert.ToInt32(txtdias.Text);
            N2 = Convert.ToInt32(txthora.Text);

            Resultado       = N2 * 8;
            Resultado2      = Resultado * N1;
            txtinicial.Text = Resultado2.ToString();
        }
Exemplo n.º 3
0
        private void btnsueldofinal_Click(object sender, EventArgs e)
        {
            String txtN3;
            string txtN4;
            float  N3;
            float  N4;
            float  Resultado;
            float  Resultado2;
            float  Resultado3;
            float  Resultado4;
            float  Resultado5;
            float  Resultado6;
            double icr    = 0.23;
            double seguro = 0.05;
            double ahorro = 0.10;

            txtN3 = txtinicial.Text;
            txtN4 = txtprestamo.Text;
            N3    = Convert.ToInt32(txtinicial.Text);
            N4    = Convert.ToInt32(txtprestamo.Text);

            Resultado   = (float)(N3 * icr);
            txtisr.Text = Resultado.ToString();

            Resultado2     = (float)(N3 * seguro);
            txtseguro.Text = Resultado2.ToString();

            Resultado3     = (float)(N3 * ahorro);
            txtahorro.Text = Resultado3.ToString();

            Resultado4       = N4;
            txtprestamo.Text = Resultado4.ToString();

            Resultado5 = Resultado + Resultado2 + Resultado3 + Resultado4;

            Resultado6    = N3 - Resultado5;
            txtfinal.Text = Resultado6.ToString();
        }
Exemplo n.º 4
0
        private void Ok_Click(object sender, EventArgs e)
        {
            int Tentativa1, Tentativa2, Tentativa3;

            relogio.Stop();
            Resp1.ReadOnly = true;
            Resp2.ReadOnly = true;
            Resp3.ReadOnly = true;
            bool Pode;

            Pode = int.TryParse(Resp1.Text, out Tentativa1);
            Pode = int.TryParse(Resp2.Text, out Tentativa2);
            Pode = int.TryParse(Resp3.Text, out Tentativa3);
            if (!Pode)
            {
                MessageBox.Show("Entrada Inválida!");
            }
            else
            {
                Tentativa1 = int.Parse(Resp1.Text);
                Tentativa2 = int.Parse(Resp2.Text);
                Tentativa3 = int.Parse(Resp3.Text);
            }

            if (Resp1.Text == null)
            {
                Resp1.Text = "0";
            }
            if (Resp2.Text == null)
            {
                Resp2.Text = "0";
            }
            if (Resp3.Text == null)
            {
                Resp3.Text = "0";
            }
            else
            {
                List <string> Lista     = new List <string>();
                int           ponto     = 0;
                string[]      mensagens = new string[3];
                if (Resultado1 == Tentativa1)
                {
                    Res1.Text      = "Certo!";
                    Res1.ForeColor = Color.Green;
                    ponto++;
                }
                else
                {
                    Res1.Text      = "Errado!";
                    Res1.ForeColor = Color.Red;
                    string erro = "Resposta da questão 1: " + Resultado1.ToString();
                    Lista.Add(erro);
                }
                if (Resultado2 == Tentativa2)
                {
                    Res2.Text      = "Certo!";
                    Res2.ForeColor = Color.Green;
                    ponto++;
                }
                else
                {
                    Res2.Text      = "Errado!";
                    Res2.ForeColor = Color.Red;
                    string erro = "Resposta da questão 2: " + Resultado2.ToString();
                    Lista.Add(erro);
                }
                if (Resultado3 == Tentativa3)
                {
                    Res3.Text      = "Certo!";
                    Res3.ForeColor = Color.Green;
                    ponto++;
                }
                else
                {
                    Res3.Text      = "Errado!";
                    Res3.ForeColor = Color.Red;
                    string erro = "Resposta da questão 3: " + Resultado3.ToString();
                    Lista.Add(erro);
                }
                if (ponto == 3)
                {
                    MessageBox.Show("Muito bem! Você acertou todas as questões :D");
                }
                else
                {
                    string s = "Oops, parece que houveram alguns erros! Veja-os abaixo: \n";
                    foreach (string x in Lista)
                    {
                        s += x + "\n";
                    }
                    MessageBox.Show(s);
                }
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            /*
             * Entradas:
             * Numero a
             * Numero b
             * Salidas:
             * Resultado suma
             * Resultado resta
             * Resultado multiplicacion
             * Resultado division
             * Resultado div
             * Resultado mod
             * Procesos:
             * Leer número a y b
             * Calcular suma: a + b
             * Calcular resta: a - b
             * Calcular multiplicacion: a * b
             * Calcular division: a / b
             * Calcular div: a / b (Trabajar sin decimales)
             * Calcular mod: a % b
             */

            int    a, b;
            int    c;
            int    Rsuma, Rresta, Rmulti, Rdiv, Rmod;
            double Rdivision;

            Console.WriteLine("EJERCICIO 1: Operaciones Aritméticas");

            // Nota: Existen dos formas de convertir datos a enteros: Convert.ToInt() e int.Parse()

            Console.WriteLine("Ingrese número a:");
            a = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Ingrese número b:");
            b = int.Parse(Console.ReadLine());

            Console.WriteLine("Ingrese número c:");
            c = Convert.ToInt16(Console.ReadLine());


            Rsuma     = a + b;
            Rresta    = a - b;
            Rmulti    = a * b;
            Rdivision = Convert.ToDouble(a) / Convert.ToDouble(b);
            Rdiv      = a / b;
            Rmod      = a % b;

            Console.WriteLine("\n" + a.ToString() + " + " + b.ToString() + " = " + Rsuma.ToString());
            Console.WriteLine(a.ToString() + " - " + b.ToString() + " = " + Rresta.ToString());
            Console.WriteLine(a.ToString() + " * " + b.ToString() + " = " + Rmulti.ToString());
            Console.WriteLine(a.ToString() + " / " + b.ToString() + " = " + Rdivision.ToString());
            Console.WriteLine(a.ToString() + " DIV " + b.ToString() + " = " + Rdiv.ToString());
            Console.WriteLine(a.ToString() + " MOD " + b.ToString() + " = " + Rmod.ToString());

            Console.ReadKey();

            //Inicia Ejercicio 2

            Console.WriteLine("\nEJERCICIO 2: Operaciones Booleanas");

            bool rmayorque, rmenorque, rigualque;

            rmayorque = a > b;
            rmenorque = a < b;
            rigualque = a == b;

            Console.WriteLine("\n" + a.ToString() + " > " + b.ToString() + " = " + rmayorque.ToString());
            Console.WriteLine(a.ToString() + " < " + b.ToString() + " = " + rmenorque.ToString());
            Console.WriteLine(a.ToString() + " == " + b.ToString() + " = " + rigualque.ToString());

            Console.ReadKey();


            //Inicia Ejercicio 3

            Console.WriteLine("\nEJERCICIO 3: Operaciones");

            int    Roperacion1, Roperacion2;
            double Roperacion3, Roperacion4;

            Roperacion1 = a * b + c;
            Roperacion2 = a * (b + c);
            Roperacion3 = Convert.ToDouble(a) / (Convert.ToDouble(b) * Convert.ToDouble(c));
            Roperacion4 = Convert.ToDouble(3 * a + 2 * b) / Convert.ToDouble(c * c);

            Console.WriteLine(a.ToString() + " * " + b.ToString() + " + " + c.ToString() + " = " + Roperacion1.ToString());
            Console.WriteLine(a.ToString() + " * " + "(" + b.ToString() + " + " + c.ToString() + ")" + " = " + Roperacion2.ToString());
            Console.WriteLine(a.ToString() + " / (" + b.ToString() + " * " + c.ToString() + ") = " + Roperacion3.ToString());
            Console.WriteLine("3(" + a.ToString() + ") + 2(" + b.ToString() + ") / " + c.ToString() + "²" + " = " + Roperacion4.ToString());

            Console.ReadKey();

            //Inicia Ejercicio 4

            Console.WriteLine("\nEJERCICIO 4: Formula Cuadratica");

            double Resultado1, Resultado2;

            Resultado1 = (-(b) + Math.Sqrt(Math.Pow(b, 2) - 4 * a * c) / 2 * a);
            Resultado2 = (-(b) - Math.Sqrt(Math.Pow(b, 2) - 4 * a * c) / 2 * a);


            Console.WriteLine($"El resultado de la operación es: {Resultado1.ToString()} y {Resultado2.ToString()}");

            Console.ReadKey();
        }