sfrsnyz

Нархов ЯП ЛАБА 6

May 5th, 2021
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. //////////// Main
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Lambda lambda=new Lambda();
  5.         lambda.geometry((value -> { // cos с помощью лямбда
  6.             System.out.printf("cos(%s)= %s%n",value,Math.round(Math.sin(value)*100)/100.0);
  7.         }));
  8.         lambda.geometry((value -> { // sin с помощью лямбда
  9.             System.out.printf("sin(%s)= %s%n",value,Math.round(Math.sin(value)*100)/100.0);
  10.         }));
  11.         lambda.geometry((value -> { // arccos с помощью лямбда
  12.             System.out.printf("arccos(%s)= %s°%n",value,Math.round(Math.acos(value)*57*100)/100.0);
  13.         }));
  14.  
  15.     }
  16. }
  17.  
  18. ///////////// Lambdable
  19. public interface Lambdable {
  20.     void testing(double value);
  21. }
  22.  
  23. //////////// Lambda
  24. import java.util.Scanner;
  25.  
  26. public class Lambda {
  27.     public void geometry(Lambdable lambdable){
  28.         Scanner scanner=new Scanner(System.in);
  29.         System.out.println("Введите число: ");
  30.         double value=scanner.nextDouble();
  31.         lambdable.testing(value);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment