Advertisement
sfrsnyz

Sviridov Yap 7

May 21st, 2021
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.PrintWriter;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7. public static void main(String[] args) throws FileNotFoundException {
  8. PrintWriter print1=new PrintWriter(new File("First.txt"));
  9. PrintWriter print2=new PrintWriter(new File("Second.txt"));
  10. PrintWriter print3=new PrintWriter(new File("Third.txt"));
  11. WorkingClas.working(() -> { //вывод синусов чисел исходного файла
  12. Scanner scan=new Scanner(new File("In.txt"));
  13. while (scan.hasNext()){
  14. int val=scan.nextInt();
  15. print1.println(String.format("sin(%s)=%s",val,Math.sin(Math.toRadians(val))));
  16. }
  17. print1.close();
  18. scan.close();
  19. });
  20. WorkingClas.working(() -> { //вывод косинусов чисел исходного файла
  21. Scanner scan=new Scanner(new File("In.txt"));
  22. while (scan.hasNext()){
  23. int val=scan.nextInt();
  24. print2.println(String.format("cos(%s)=%s",val,Math.cos(Math.toRadians(val))));
  25. }
  26. print2.close();
  27. scan.close();
  28. });
  29. WorkingClas.working(() -> { //вывод тангенсов чисел исходного файла
  30. Scanner scan=new Scanner(new File("In.txt"));
  31. while (scan.hasNext()){
  32. int val=scan.nextInt();
  33. print3.println(String.format("tg(%s)=%s",val,Math.tan(Math.toRadians(val))));
  34. }
  35. print3.close();
  36. scan.close();
  37. });
  38. }
  39. }
  40.  
  41. ///////////////
  42.  
  43.  
  44. import java.io.FileNotFoundException;
  45.  
  46. public class WorkingClas {
  47. public static void working(WorkingInterface workingInterface) throws FileNotFoundException {
  48. workingInterface.work();
  49. }
  50. }
  51. ///////////
  52.  
  53.  
  54. import java.io.FileNotFoundException;
  55.  
  56. public interface WorkingInterface {
  57. void work() throws FileNotFoundException;
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement