Advertisement
Guest User

Untitled

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