Advertisement
ValerioBellic

Untitled

Nov 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class quadrato
  4. {
  5.  
  6.     static InputStreamReader input= new InputStreamReader (System.in);
  7.     static BufferedReader tastiera= new BufferedReader (input);
  8.    
  9.    
  10.     private static double lato=0;
  11.    
  12.     public static void setlato()
  13.     {
  14.     do
  15.     {
  16.         System.out.print("inserisci il lato del quadrato");
  17.         try
  18.         {
  19.              String latoletto = tastiera.readLine();
  20.              lato = double.valueOf(latoletto).doubleValue();
  21.         }
  22.         catch(Exception e)
  23.         {
  24.         System.out.println("Errore! Inserisci un valore positivo");
  25.         }
  26.         while (lato < 0);
  27.            
  28.         }
  29.     }  
  30.    
  31.     public static double setper()
  32.     {
  33.         double perim;
  34.         perim = lato * 4;
  35.         return perim;
  36.     }
  37.    
  38.     public static double setarea()
  39.         {
  40.         double area;
  41.         area = lato * 4;
  42.         return area;
  43.         }
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement