Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.nio.charset.Charset;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.text.DecimalFormat;
- import java.util.List;
- import java.util.Scanner;
- public class t766 {
- public static void main(String[] args) throws Exception{
- FileReader fr = new FileReader ("input.txt");
- FileWriter fw = new FileWriter ("output.txt");
- Scanner in = new Scanner(fr);
- double m=0;
- int i=0;
- List<String> lines = Files.readAllLines(Paths.get("input.txt"), Charset.defaultCharset());
- for (String x:lines)
- {
- m+=Integer.parseInt(lines.get(i));
- i++;
- }
- in.close();
- fr.close();
- String formattedDouble = new DecimalFormat("#0.000").format(m/i);
- fw.write(formattedDouble);
- fw.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement