madhawaseeeee

myabsrtractprocess

Sep 17th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1.  
  2. abstract class MyAbstractProcess {
  3.  
  4.     public String[] readValues() {
  5.  
  6.         String y[] = {"1", "3", "9", "4", "7", "60", "0", "8", "2", "5"};
  7.         return y;
  8.  
  9.     }
  10.  
  11.     public String action2() {
  12.  
  13.         String x[] = readValues();
  14.  
  15.         double total = 0;
  16.         int max = Integer.parseInt(x[0]);
  17.         int min = Integer.parseInt(x[0]);
  18.  
  19.         for (int i = 0; i < x.length; i++) {
  20.  
  21.             int currentNumber = Integer.parseInt(x[i]);
  22.  
  23.             total = total + currentNumber;
  24.  
  25.             if (max < currentNumber) {
  26.  
  27.                 max = currentNumber;
  28.             } else if (min > currentNumber) {
  29.  
  30.                 min = currentNumber;
  31.             }
  32.  
  33.         }
  34.  
  35.         double avg = total / x.length;
  36.         return "avg" + avg + "max" + max + "min" + min;      
  37.  
  38.     }
  39.    
  40.     public abstract int action();
  41.    
  42.     public void printValue() {
  43.        
  44.         System.out.println(action());
  45.        
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment