Example #1
0
        void calcularButton_Click(object sender, EventArgs e)
        {
            switch (codigoDoExercicio)
            {
            case 4:
                try
                {
                    respostaLabel.Text = MetodosDoExercicio.Exercicio4(Convert.ToDouble(notaTextBox.Text));
                    notaTextBox.Text   = "0";


                    break;
                }
                catch (FormatException)
                {
                    MessageBox.Show("Formato inválido");
                    break;
                }

            case 6:
                try
                {
                    respostaLabel.Text  = MetodosDoExercicio.Exercicio6a(notaTextBox.Text);
                    respostaLabel3.Text = MetodosDoExercicio.Exercicio6b(notaTextBox.Text);
                    notaTextBox.Text    = "";
                    break;
                }
                catch (FormatException)
                {
                    MessageBox.Show("Formato inválido");
                    break;
                }

            case 8:
                respostaLabel.Text = "Notas Maiores que a média\n" +
                                     MetodosDoExercicio.Exercicio8a(nota).ToString();
                respostaLabel2.Text = "Notas Menores do que a média\n" +
                                      MetodosDoExercicio.Exercicio8b(nota).ToString();
                respostaLabel3.Text = nota.Count.ToString();
                nota.Clear();
                break;

            case 9:
                respostaLabel.Text = MetodosDoExercicio.Exercicio9(listaDeAlunos);
                listaDeAlunos.Clear();

                break;

            case 10:
                respostaLabel.Text = MetodosDoExercicio.Exercicio10(salarios);
                salarios.Clear();
                break;
            }
        }
Example #2
0
 private void exercicio3Button_Click(object sender, EventArgs e)
 {
     respostaLabel.Text     = "";
     respostaLabel2.Visible = false;
     respostaLabel3.Visible = false;
     enunciadoLabel.Visible = false;
     notaTextBox.Visible    = false;
     calcularButton.Visible = false;
     respostaLabel.Text     = MetodosDoExercicio.Exercicio3();
     notaLabel.Visible      = false;
     nomeLabel.Visible      = false;
     nomeTextBox.Visible    = false;
     addNotaButton.Visible  = false;
 }
Example #3
0
        public void addNotaButton_Click_1(object sender, EventArgs e)
        {
            switch (codigoDoExercicio)
            {
            case 8:
                try
                {
                    notaTextBox.Focus();
                    if (Convert.ToDouble(notaTextBox.Text) < 0)
                    {
                        throw new ApplicationException
                                  ("Sabemos que o aluno é ruim, mas nota negativa não pode.");
                    }
                    nota.Add(notaTextBox.Text);
                    notaTextBox.Clear();
                    respostaLabel3.Text = nota.Count.ToString();
                }
                catch (FormatException)
                {
                    MessageBox.Show("Formato inválido");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case 9:
                try

                {
                    nomeTextBox.Focus();
                    if (Convert.ToDouble(notaTextBox.Text) < 0)
                    {
                        throw new ApplicationException
                                  ("Sabemos que o aluno é ruim, mas nota negativa não pode.");
                    }


                    listaDeAlunos.Add(new Aluno()
                    {
                        nome = nomeTextBox.Text,
                        nota = notaTextBox.Text
                    });

                    nomeTextBox.Clear();
                    notaTextBox.Clear();
                    respostaLabel3.Text = "Numero de alunos: " + listaDeAlunos.Count.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                break;

            case 10:
                try
                {
                    nomeTextBox.Focus();
                    if (nomeTextBox.Text.Equals("-1"))
                    {
                        respostaLabel.Text = MetodosDoExercicio.Exercicio10(salarios);
                        break;
                    }

                    if (Convert.ToDecimal(nomeTextBox.Text) < -1)
                    {
                        throw new ApplicationException
                                  ("Salario muito baixo");
                    }
                    salarios.Add(nomeTextBox.Text);
                    nomeTextBox.Clear();
                    respostaLabel3.Text =
                        "Quantidade de salários adicionados: " + salarios.Count.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                break;
            }
        }