Advertisement
sergAccount

Untitled

Jan 30th, 2021
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app4;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class AvgTask implements Runnable {
  13.  
  14.     private int[] array;
  15.     private double result;
  16.  
  17.     public AvgTask(int[] array) {
  18.         this.array = array;
  19.     }
  20.     // метод для получения результата
  21.     public double getResult() {
  22.         return result;
  23.     }
  24.     @Override
  25.     public void run() {
  26.         for (int i = 0; i < array.length; i++) {
  27.             result += array[i];
  28.         }
  29.         result = result / array.length;
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement