Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package calculator;
- import java.util.Scanner;
- public class Calculator {
- public static void main(String[] args) {
- Scanner sc = new Scanner (System.in);
- System.out.print("Introduceti prima latura: ");
- int a = sc.nextInt();
- System.out.print("Introduceti a doua latura: ");
- int b = sc.nextInt();
- System.out.print("Introduceti ungiu opus laturei necunoscute: ");
- int C = sc.nextInt();
- System.out.println("Lungimea laturei necunoscute este: "+aplicaTeorema(a,b,C));
- }
- public static double aplicaTeorema(int a, int b, int C) {
- //c = radical(a2+b2-2abcosC)
- double c = Math.sqrt( (a*a) + (b*b) - 2*a*b*Cos(C));
- return c;
- }
- public static double Cos(double Exp)
- {
- if (Exp == 90.00)
- return 0.00;
- else
- return Math.cos( Math.toRadians(Exp) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement