Shavit

Pythagoras

Oct 8th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Pythagoras {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.         double a, b, c, s;
  13.        
  14.         System.out.println("Enter the values of a and b:");
  15.         a = in.nextDouble();
  16.         b = in.nextDouble();
  17.        
  18.         c = Math.sqrt(Math.pow(a,2)+Math.pow(b,2));
  19.         s = (a*b)/2;
  20.        
  21.         System.out.printf("The value of c is %.3f, the surface area is %.3f.", c, s);
  22.        
  23.         in.close();
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment