Пример #1
0
        //Porcentagem
        private void BtPorc_Click(object sender, EventArgs e)
        {
            ValorSecundario = double.Parse(LbValor.Text);
            double Resposta;

            // Soma
            if (Operacao == 1)
            {
                Resposta     = ValorPrimario * (ValorSecundario / 100);
                Resposta     = Resposta + ValorPrimario;
                LbValor.Text = Resposta.ToString();
            }
            // Subtracao
            if (Operacao == 2)
            {
                Resposta     = ValorPrimario * (ValorSecundario / 100);
                Resposta     = Resposta - ValorPrimario;
                LbValor.Text = Resposta.ToString();
            }
            // Multiplicacao
            if (Operacao == 3)
            {
                Resposta     = ValorPrimario * (ValorSecundario / 100);
                Resposta     = Resposta * ValorPrimario;
                LbValor.Text = Resposta.ToString();
            }
            //Divisao
            if (Operacao == 4)
            {
                Resposta     = ValorPrimario * (ValorSecundario / 100);
                Resposta     = Resposta / ValorPrimario;
                LbValor.Text = Resposta.ToString();
            }
        }
Пример #2
0
        //Raiz Quadrada
        private void BtRaiz_Click(object sender, EventArgs e)
        {
            double Resposta, Valor;

            Valor        = double.Parse(LbValor.Text);
            Resposta     = Convert.ToSingle(Math.Sqrt(Valor));
            LbValor.Text = Resposta.ToString();
        }
Пример #3
0
        public void Checar()
        {
            lblNumS.Text = Convert.ToString(numero1);


            int numero;

            try
            {
                numero = int.Parse(txtNumero.Text);
                if (chances > 0)
                {
                    if (numero == numero1)
                    {
                        acertos++;
                        lblAcerto.Text = Convert.ToString(acertos);
                        DialogResult Resposta;
                        Resposta = MessageBox.Show("Parabens você acertou!\n Quer tentar de novo?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        if (Resposta.ToString() == "Yes")
                        {
                            numero1      = numerosorte();
                            lblNumS.Text = Convert.ToString(numero1);
                            lstBoxNumErrados.Items.Clear();
                            txtNumero.Focus();
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else if (numero < numero1)
                    {
                        MessageBox.Show("O Numero digitado é menor que o Numero da Sorte");
                        chances--;
                        tentativas++;
                        lblTentativas.Text = Convert.ToString(tentativas);
                        lblChances.Text    = Convert.ToString(chances);
                        txtNumero.Focus();

                        lstBoxNumErrados.Items.Add(Convert.ToString(txtNumero.Text));
                    }
                    else
                    {
                        MessageBox.Show("O Numero digitado é maior que o Numero da Sorte");
                        chances--;
                        tentativas++;
                        lblTentativas.Text = Convert.ToString(tentativas);
                        lblChances.Text    = Convert.ToString(chances);
                        txtNumero.Focus();
                        lstBoxNumErrados.Items.Add(Convert.ToString(txtNumero.Text));
                    }
                }
                else
                {
                    DialogResult Resposta;
                    Resposta = MessageBox.Show("Acabou suas chances! Quer gerar um novo numero?", "Perdeu", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (Resposta.ToString() == "Yes")
                    {
                        numero1         = numerosorte();
                        chances         = 10;
                        lblChances.Text = Convert.ToString(chances);
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Digite um numero por favor!");
                txtNumero.Text = "";
                txtNumero.Focus();
            }
        }