SHARE
TWEET

Untitled

a guest Sep 16th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package harj2;
  2.  
  3. public class Suorakulmio
  4. {
  5.     private double x1;
  6.     private double y1;
  7.     private double x2;
  8.     private double y2;
  9.  
  10. public Suorakulmio()
  11. {
  12.     x1=0;
  13.     y1=0;
  14.     x2=1;
  15.     y2=1;  
  16. }
  17.  
  18. public Suorakulmio(double _x2, double _y2)
  19. {
  20.     x1=0;
  21.     y1=0;
  22. }
  23.  
  24. public Suorakulmio(double _x1, double _y1, double _x2, double _y2)
  25. {
  26.     x1= _x1;
  27.     y1= _y1;
  28.     x2= _x2;
  29.     y2= _y2;   
  30. }
  31.  
  32.  
  33. public double kanta() {
  34.     return x2-x1;
  35. }
  36.  
  37.  
  38. public double korkeus() {
  39.     return y2-y1;
  40. }
  41.  
  42.  
  43. public double pintaAla() {
  44.     return kanta() * korkeus();
  45. }
  46.  
  47.  
  48. public static void main(String[] args)
  49. {
  50.     Suorakulmio test = new Suorakulmio();
  51.     System.out.println("Kannan pituus= " + test.kanta() + "\nKorkeus= " + test.korkeus() +  "\nPinta-ala= " + test.pintaAla());
  52.  
  53.    
  54. }
  55.    
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top