Advertisement
elsemTim

new try

Jul 29th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. public class Test {
  2.  
  3.     private double percentile = 0.00;
  4.     private double median = 0.00;
  5.     private double maxValue = Double.MIN_VALUE;
  6.     private double minValue = Double.MAX_VALUE;
  7.     private double avrgValue = 0.00;
  8.  
  9.     public void main(String[] args) throws IOException {
  10.         if (args.length < 1) {
  11.             System.out.println("Ошибка: отсуствует файл с входными данными");
  12.         }
  13.         Scanner reader = new Scanner(new FileInputStream(args[0]));
  14.         int linesInFile = reader.nextInt();
  15.         double[] data = new double[linesInFile];
  16.         for (int i = 0; i <= linesInFile; i++) {
  17.             double number = Double.parseDouble(reader.nextLine().trim());
  18.             BigDecimal numberForCompare = BigDecimal.valueOf(number);
  19.             numberForCompare.setScale(2, RoundingMode.CEILING);
  20.             if (numberForCompare.compareTo(BigDecimal.valueOf(maxValue)) > 0) {
  21.                 maxValue = numberForCompare.doubleValue();
  22.             }
  23.             if (numberForCompare.compareTo(BigDecimal.valueOf(minValue)) < 0) {
  24.                 minValue = numberForCompare.doubleValue();
  25.             }
  26.             data[i] = number;
  27.         }
  28.  
  29.         for (int i = 0; i < data.length; i++) {
  30.             //TODO здесь написать код, который тебе нужен
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement