Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.io.DataOutputStream;
  2. import java.io.FileOutputStream;
  3. import java.io.FileWriter;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.util.Random;
  7.  
  8. import org.apache.commons.lang3.RandomStringUtils; // Posrednik
  9.  
  10. public class Plik {
  11.  
  12.     public static void main(String[] args) throws IOException {
  13.                
  14.         Random random = new Random();
  15.        
  16.         int s= random.nextInt() % 100 + 50;
  17.         System.out.println(s);
  18.        
  19.         PrintWriter zapis = new PrintWriter("posrednik.txt");
  20.        
  21.         String imie, nazwisko;
  22.        
  23.         String telefon;
  24.        
  25.        
  26.         int wiek;
  27.        
  28.         int biuro;
  29.        
  30.        
  31.         int nr;
  32.        
  33.         for (int i=0;i<1500000;i++) {
  34.             telefon = "";
  35.             imie = RandomStringUtils.randomAlphabetic(5);
  36.             nazwisko = RandomStringUtils.randomAlphabetic(5);
  37.            
  38.             String []plec = {"mezczyzna", "kobieta"};
  39.             do {
  40.                 wiek = (random.nextInt() % 59);
  41.                 biuro = (random.nextInt() % 101);
  42.             } while(wiek<0 || biuro<=0);
  43.             wiek +=18;
  44.            
  45.             for(int j=0;j<3;j++)
  46.             {
  47.                 do
  48.                 {
  49.                 nr = random.nextInt() % 1000;
  50.                 } while(nr<0 || nr < 100 || nr >=1000);
  51.             if(j!=2) telefon +=nr+"-";
  52.             else telefon+=nr;
  53.             }
  54.            
  55.             zapis.println(imie +", " + nazwisko+", " +telefon+", " +biuro+ "," + wiek + "," +plec[wiek % 2] );
  56.         }
  57.            
  58.         zapis.close();
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement