Advertisement
ValerioBellic

Untitled

Nov 26th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class programma2
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         double somma;
  8.         int n;
  9.         quadrato vetq[];
  10.        
  11. InputStreamReader input= new InputStreamReader (System.in);
  12. BufferedReader tastiera= new BufferedReader (input);
  13.        
  14. do
  15. {
  16.     System.out.print("inserisci il numero di quadrati");
  17.     try
  18.     {
  19.          String numeroletto = tastiera.readLine();
  20.          n = integer.valueOf(numeroletto).intvalue();
  21.     }
  22.     catch(Exception e)
  23.     {
  24.     System.out.println("Errore! Inserisci un valore intero positivo");
  25.     }
  26. }
  27.     while (n < 0);
  28.    
  29.     vetq[] = new quadrato[N];
  30.     for (int i=0;i<vetq.lenght;i++)
  31.     {
  32.         vetq[i] = new quadrato();
  33.     }
  34.    
  35.     for (int i=0;i<vetq.lenght;i++)
  36.     {
  37.         vetq[i].setlato();
  38.         somma = somma + vetq[i].setarea();
  39.        
  40.     }
  41.    
  42.     System.out.println("la somma delle aree di tutti i quadrati e' " + somma);
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement