Created
November 12, 2014 11:45
-
-
Save pbalduino/74c319cd5e502d3f0dbb to your computer and use it in GitHub Desktop.
Cálculo de média sem array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void btnCalcular_Click(object sender, EventArgs e) | |
| { | |
| decimal maior = 0; | |
| decimal menor = 99; | |
| if (txtNota0.Value < menor) menor = txtNota0.Value; | |
| if (txtNota1.Value < menor) menor = txtNota1.Value; | |
| if (txtNota2.Value < menor) menor = txtNota2.Value; | |
| if (txtNota3.Value < menor) menor = txtNota3.Value; | |
| lblMenor.Text = menor.ToString(); | |
| if (txtNota0.Value > maior) maior = txtNota0.Value; | |
| if (txtNota1.Value > maior) maior = txtNota1.Value; | |
| if (txtNota2.Value > maior) maior = txtNota2.Value; | |
| if (txtNota3.Value > maior) maior = txtNota3.Value; | |
| lblMaior.Text = maior.ToString(); | |
| decimal media = (txtNota0.Value + txtNota1.Value + txtNota2.Value + txtNota3.Value) / 4; | |
| lblMedia.Text = media.ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment