Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class uppg4_moment4
- {
- public static void main(String [] args)
- {
- String a = JOptionPane.showInputDialog("Ange den första kateten: ");
- String b =JOptionPane.showInputDialog("Ange den andra kateten: ");
- double hypotenusa = hypotenusa(a, b);
- JOptionPane.showMessageDialog(null, hypotenusa);
- calculator svar = new calculator();
- svar.hypotenusa(a,b);
- }
- class calculator {
- public double hypotenusa(String a, String b)
- {
- double Katet1=Double.parseDouble(a);
- double Katet2=Double.parseDouble(b);
- double hypotenusa = Math.sqrt(Math.pow(Katet1, 2) + Math.pow(Katet2, 2));
- return hypotenusa;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement