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 printWriter1=new PrintWriter(new File("First.txt"));
- PrintWriter printWriter2=new PrintWriter(new File("Second.txt"));
- PrintWriter printWriter3=new PrintWriter(new File("Third.txt"));
- Fileworker.sqrt(() -> { //извлечение корня 2 степени
- Scanner read= new Scanner(new File("In.txt"));
- while (read.hasNext()){
- int value=read.nextInt();
- double sqrt=Math.round(Math.sqrt(value)*100)/100.0;
- printWriter1.println(String.format("√%s=%s",value,sqrt));
- }
- printWriter1.close();
- read.close();
- });
- Fileworker.sqrt(() -> { //извлечение корня 3 степени
- Scanner read= new Scanner(new File("In.txt"));
- while (read.hasNext()){
- int value=read.nextInt();
- double sqrt=Math.round(Math.pow(value,1/3.0)*100)/100.0;
- printWriter2.println(String.format("∛%s=%s",value,sqrt));
- }
- printWriter2.close();
- read.close();
- });
- Fileworker.sqrt(() -> { //извлечение корня 4 степени
- Scanner read= new Scanner(new File("In.txt"));
- while (read.hasNext()){
- int value=read.nextInt();
- double sqrt=Math.round(Math.pow(value,1/4.0)*100)/100.0;
- printWriter3.println(String.format("∜%s=%s",value,sqrt));
- }
- printWriter3.close();
- read.close();
- });
- }
- }
- //////////////
- import java.io.FileNotFoundException;
- public class Fileworker {
- public static void sqrt(Fileable fileable) throws FileNotFoundException {
- fileable.sqrtable();
- }
- }
- ////////////
- import java.io.FileNotFoundException;
- public interface Fileable {
- void sqrtable() throws FileNotFoundException;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement