leniuch

pesel_termin1_2020

Feb 25th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. public class pesel {
  2.     static int max = 0;
  3.     static String maxx;
  4.     static int doemerytury;
  5.     static int dataa;
  6.     static int wiek;
  7.     static String data;
  8.     static String fix(String filename) throws FileNotFoundException {
  9.        
  10.     try{
  11.     RandomAccessFile raf = new RandomAccessFile(filename, "rw");
  12.    
  13.     String line;
  14.    
  15.     while( (line=raf.readLine())!=null ){
  16.     String imie = line;
  17.     String nazwisko = raf.readLine();
  18.     char plec = raf.readLine().charAt(0);
  19.     long pesel = Long.parseLong(raf.readLine());
  20.    
  21.     long pos1 = raf.getFilePointer();
  22.     raf.writeBytes("   ");
  23.    
  24.     String pestring = Long.toString(pesel);
  25.    
  26.     String l1 = Character.toString(pestring.charAt(0));
  27.     String l2 = Character.toString(pestring.charAt(1));
  28.    
  29.     if(pestring.length()==11){
  30.     data = "19"+l1+l2;}
  31.     else { data = "20"+l1+l2;}
  32.    
  33.     dataa = Integer.parseInt(data);
  34.     wiek = 2020-dataa;
  35.    
  36.     if(plec=='K'){ doemerytury = 60-wiek; }
  37.     if(plec=='M'){ doemerytury = 65-wiek; }
  38.     raf.seek(pos1);
  39.     raf.writeBytes(Integer.toString(doemerytury));
  40.    
  41.     if(doemerytury>max){maxx=imie+" "+nazwisko;}
  42.    
  43.     raf.readLine();
  44.     }
  45.    
  46.     raf.close();
  47.     }
  48.     catch (Exception e){System.out.println(e);}
  49.      
  50.     return maxx;}
Add Comment
Please, Sign In to add comment