Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package calculator;
  2. import java.util.Scanner;
  3.  
  4. public class Calculator {
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner (System.in);
  7. System.out.print("Introduceti prima latura: ");
  8. int a = sc.nextInt();
  9.  
  10. System.out.print("Introduceti a doua latura: ");
  11. int b = sc.nextInt();
  12.  
  13. System.out.print("Introduceti ungiu opus laturei necunoscute: ");
  14. int C = sc.nextInt();
  15.  
  16. System.out.println("Lungimea laturei necunoscute este: "+aplicaTeorema(a,b,C));
  17. }
  18. public static double aplicaTeorema(int a, int b, int C) {
  19. //c = radical(a2+b2-2abcosC)
  20. double c = Math.sqrt( (a*a) + (b*b) - 2*a*b*Cos(C));
  21. return c;
  22. }
  23.  
  24. public static double Cos(double Exp)
  25. {
  26. if (Exp == 90.00)
  27. return 0.00;
  28. else
  29. return Math.cos( Math.toRadians(Exp) );
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement