Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws FileNotFoundException {
- PrintWriter print1=new PrintWriter(new File("First.txt"));
- PrintWriter print2=new PrintWriter(new File("Second.txt"));
- PrintWriter print3=new PrintWriter(new File("Third.txt"));
- WorkingClas.working(() -> { //вывод синусов чисел исходного файла
- Scanner scan=new Scanner(new File("In.txt"));
- while (scan.hasNext()){
- int val=scan.nextInt();
- print1.println(String.format("sin(%s)=%s",val,Math.sin(Math.toRadians(val))));
- }
- print1.close();
- scan.close();
- });
- WorkingClas.working(() -> { //вывод косинусов чисел исходного файла
- Scanner scan=new Scanner(new File("In.txt"));
- while (scan.hasNext()){
- int val=scan.nextInt();
- print2.println(String.format("cos(%s)=%s",val,Math.cos(Math.toRadians(val))));
- }
- print2.close();
- scan.close();
- });
- WorkingClas.working(() -> { //вывод тангенсов чисел исходного файла
- Scanner scan=new Scanner(new File("In.txt"));
- while (scan.hasNext()){
- int val=scan.nextInt();
- print3.println(String.format("tg(%s)=%s",val,Math.tan(Math.toRadians(val))));
- }
- print3.close();
- scan.close();
- });
- }
- }
- ///////////////
- import java.io.FileNotFoundException;
- public class WorkingClas {
- public static void working(WorkingInterface workingInterface) throws FileNotFoundException {
- workingInterface.work();
- }
- }
- ///////////
- import java.io.FileNotFoundException;
- public interface WorkingInterface {
- void work() throws FileNotFoundException;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement