Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class uppg4_moment4
  4. {
  5.     public static void main(String [] args)
  6.     {
  7.         String a = JOptionPane.showInputDialog("Ange den första kateten: ");            
  8.         String b =JOptionPane.showInputDialog("Ange den andra kateten: ");        
  9.         double hypotenusa = hypotenusa(a, b);
  10.         JOptionPane.showMessageDialog(null, hypotenusa);
  11.        
  12.             calculator svar = new calculator();
  13.             svar.hypotenusa(a,b);
  14.        
  15.     }
  16. class calculator {
  17.     public double hypotenusa(String a, String b)
  18.     {  
  19.         double Katet1=Double.parseDouble(a);
  20.         double Katet2=Double.parseDouble(b);
  21.         double hypotenusa = Math.sqrt(Math.pow(Katet1, 2) + Math.pow(Katet2, 2));
  22.         return hypotenusa;
  23.            
  24.     }  
  25. }
  26.        
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement