Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. private static double getAverage(double oceneGet, double countGet, int decimal) {
  2.  
  3.        
  4.         //Določi število desetic iz decimalnega mesta
  5.         int finalDecimal = (int) Math.pow(10, decimal);
  6.         //Dobi povprečje
  7.         double stage1 = oceneGet / countGet;
  8.         //Deli z številom desetic, glede na število decimalk ki ga hočeš
  9.         double stage2 = stage1*finalDecimal;
  10.         //Poberi vse ostale decimalke stran
  11.         int    stage3 = (int) stage2;
  12.         //Daj število nazaj v double
  13.         double stage4 = stage3;
  14.         //Pridobi nazaj decimalna mesta
  15.         double stage5 = stage4 / finalDecimal;
  16.         //Vrni vrednost
  17.         return stage5;
  18.  
  19.  
  20.  
  21.     }
Add Comment
Please, Sign In to add comment