import cache.*;

public class Simulateur_Task2 {
    private int warmupLength;
    private int cacheSize;
    private TraceParser tp = null;

    public Simulateur_Task2(String[] args) {
        this.warmupLength = Integer.parseInt(args[0]);
        this.cacheSize = Integer.parseInt(args[1]);
        this.tp = new TraceParser(System.in);
        this.simulate();
    }

    public void simulate() {
        CacheLFUbytes cacheLFUbytes = new CacheLFUbytes(cacheSize);
        CacheLRUbytes cacheLRUbytes = new CacheLRUbytes(cacheSize);
        CacheRLF cacheRLF = new CacheRLF(cacheSize);

        for (int i = 0 ; i < warmupLength ; i++) {
            RequestedObject ro = tp.getResFromFile();
            if (ro == null) break;
            cacheLFUbytes.get(ro);
            cacheLRUbytes.get(ro);
            cacheRLF.get(ro);
        }
        RequestedObject ro = null;
        int compteur = 0;
        int hitsLFUbytes = 0;
        int hitsLRUbytes = 0;
        int hitsRLF = 0;

        while((ro = tp.getResFromFile()) != null) {
            if (cacheLFUbytes.get(ro)) {
            	hitsLFUbytes++;
            }
            if (cacheLRUbytes.get(ro)) {
                 hitsLRUbytes++;
            }
            if (cacheRLF.get(ro)) {
            	hitsRLF++;
           	}
            compteur++;
        }
        double hitrateLFUbytes = (double)hitsLFUbytes / (double)compteur;
        double hitrateLRUbytes = (double)hitsLRUbytes / (double)compteur;
        double hitrateRLF = (double)hitsRLF / (double)compteur;
        System.out.println("Hits rate LFUbytes : " + hitrateLFUbytes*100 + "%");
        System.out.println("Hits rate LRUbytes : " + hitrateLRUbytes*100 + "%");
        System.out.println("Hits rate RLF : " + hitrateRLF*100 + "%");
        System.out.println("Total requests : " + compteur);
    }

}

@@ -8,16 +8,48 @@
 cache.*;
+%0Aimport java.text.DecimalFormat;
 %0A%0Apublic
@@ -165,16 +165,82 @@
  = null;
+%0A    private DecimalFormat formatter = new DecimalFormat(%220.00%25%22);
 %0A%0A    pu
@@ -1921,12 +1921,105 @@
 );%0A    %7D
+%0A    %0A    public String roundDouble(double d)%7B%0A       return formatter.format(d); %0A    %7D%0A    
 %0A%0A%7D%0A

print format