Attachment 'MediaEsami.java'

Download

   1 import javax.swing.JOptionPane;
   2 
   3 
   4 public class MediaEsami {
   5 
   6 	public static void main(String[] args) {
   7 		
   8 		int somma = 0;
   9 		int conto = 0;
  10 		int voto  = 19;
  11 		// ripeti finché non inserisco un numero < 18  
  12 		while (voto >= 18 && voto <=30)
  13 		{
  14 			String votoStringa = JOptionPane.showInputDialog("Inserisci Voto");
  15 			voto = Integer.parseInt(votoStringa);
  16 			if( voto >= 18 && voto <= 30)
  17 			{
  18 				conto = conto + 1;
  19 				somma = somma + voto;
  20 			}
  21 		}
  22 		
  23 		int media = somma / conto;
  24 		
  25 		JOptionPane.showMessageDialog(null,"La media è: "+media);
  26 		
  27 	}
  28 	
  29 }

Attached Files

You are not allowed to attach a file to this page.