Advertisement
polpoteu

JAVA Egz Domy+20%

Mar 5th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.RandomAccessFile;
  3.  
  4. public class Zadanie1 {
  5.  
  6. public static String funkcja(String nazwa) {
  7. String dom1="";
  8. int maks =0;
  9. try(RandomAccessFile raf = new RandomAccessFile(nazwa, "rw")){
  10. String dom;
  11. int liczba;
  12. double cena;
  13. long wsk;
  14.  
  15. while(raf.getFilePointer() < raf.length()) {
  16. dom = raf.readUTF();
  17. liczba = raf.readInt();
  18. wsk = raf.getFilePointer();
  19. cena = raf.readDouble();
  20.  
  21. if(liczba == 0) {
  22. raf.seek(wsk);
  23. raf.writeDouble(cena * 1.2);
  24. }
  25.  
  26. if(liczba > maks) {
  27. maks = liczba;
  28. dom1 = dom;
  29. }
  30. }
  31.  
  32.  
  33.  
  34. }catch(IOException e) {
  35. e.getMessage();
  36. }
  37.  
  38. return dom1;
  39. }
  40.  
  41.  
  42. public static void main(String[] args) {
  43.  
  44. }
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement