Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Media
- {
- public static void main (String args[])
- {
- InputStreamReader input = new InputStreamReader(System.in);
- BufferedReader tastiera = new BufferedReader(input);
- int s=0;
- System.out.println("Quanti numeri vuoi inserire?");
- try{
- String val= tastiera.readLine();
- int n= Integer.parseInt(val);
- }
- catch(Exception e)
- {
- return;
- }
- for(int i=0;i<n;i++)
- {
- System.out.println("Inserisci valore numero: " + i);
- try{
- String val= tastiera.readLine();
- int num= Integer.parseInt(val);
- }
- catch(Exception e)
- {
- return;
- }
- s=s+num;
- }
- float m= s/n;
- System.out.println("La media vale: " + m);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement