0
I made an application to calculate the arithmetic average of 3 notes. My form has 3 Textbox that receives the note and a button that calculates the average. The result is printed on a Label, as I do to limit the amount of numbers after the ","?
private void btnCalcular_Click(object sender, EventArgs e)
{
//DECLARAÇÃO DE VARIÁVEIS
double num1, num2, num3, resultado;
//CONVERSÃO DE STRING PARA DOUBLE
num1 = Convert.ToDouble(txtN1.Text);
num2 = Convert.ToDouble(txtN2.Text);
num3 = Convert.ToDouble(txtN3.Text);
//OPERAÇÃO DE CÁLCULO
resultado = (num1 + num2 + num3) / 3;
lblResult.Text = resultado.ToString();
lblResult.Text = resultado.ToString();
if (resultado >= 6)
{
MessageBox.Show("Aluno aprovado!", "Status do aluno", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Aluno reprovado", "Status do aluno", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
https://answall.com/questions/290894/casas-decimais-c
– Ricardo Pontual
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.
– Maniero