/Users/teofilomatos/Documents/isep/APROG_2011_2012/projetos/PL4_EX_DEM1/src/PL4_EX_DEM1/Main.java |
1 package PL4_EX_DEM1;
2
3 import javax.swing.JOptionPane;
4
5
6
7 @author
8
9 public class Main {
10
11
12
13
14
15
16 public static void main(String[] args) {
17 int i = 0;
18 double nota, soma = 0, media;
19 String vAuxiliar;
20
21
22 vAuxiliar = JOptionPane.showInputDialog("Qual a nota? (para terminar digite 0)");
23 nota = Double.parseDouble(vAuxiliar);
24
25
26 while (nota != 0) {
27 soma = soma + nota;
28 i++;
29
30
31 vAuxiliar = JOptionPane.showInputDialog("Qual a nota do aluno? (0 para terminar)");
32 nota = Double.parseDouble(vAuxiliar);
33 }
34
35
36
37
38
39 if (i > 0) {
40 media = soma / i;
41 JOptionPane.showMessageDialog(null, "A média das notas=" + media);
42 } else {
43 JOptionPane.showMessageDialog(null, "Não foram introduzidas notas!");
44 }
45 }
46 }
47
48