Guest User

Untitled

a guest
May 16th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class For_za_Metodu {
  4.     public static void main (String[] args) {
  5.     double [] field = new double [11];
  6.     Random lubsa = new Random();   
  7.     int i;
  8.  
  9.     for (i=1; i<=10; i++) {                     // vygenerovani pole a zaokrouhleni clenu
  10.         field[i]=lubsa.nextDouble()*10;
  11.         field[i]=Math.round(field[i]*100);
  12.         field [i]=  field[i]/100;
  13.     }
  14.     tisk  (field);                              // tisk pole pomocí medoty
  15.    
  16.    
  17.     System.out.println();
  18.  
  19.     for (i=1; i<=10; i++) {                     // upravy clenu pole
  20.         if (i % 2 == 1) {
  21.             field [i]=2*field [i];
  22.         }
  23.     }
  24.  
  25.     tisk (field);                               // tisk zmeneneho pole
  26.    
  27. }
  28.    
  29.      final static void tisk (double [] pole) {  // metoda pro tisk
  30.         for (int i=1; i<=10; i++){
  31.             System.out.print(pole [i] + "   ");
  32.     }
  33. }
  34. }
Add Comment
Please, Sign In to add comment