def yper(wr,mis):
    if wr<=10:
        yp=wr*mis/150
    else:
        yp=10*mis/150+(wr-10)*mis/120
    yp=round(yp,2)
    return yp

def ypol_kr(mis,yp):
    akath=round(mis+yp,2)
    ika1=round(akath*0.16,2)
    ika2=round(akath*0.2606,2)
    forol=round(akath-ika1,2)
    return akath,ika1,ika2,forol

def yp_forou(feis):
    fe=feis*14
    if fe<=20000:
        fo=fe*0.22
    else:
        if fe<=30000:
            fo=20000*0.22+(fe-20000)*0.29
        else:
            if fe<=40000:
                fo=20000*0.22+10000*0.29+(fe-30000)*0.37
            else:
                fo = 20000 * 0.22 + 10000 * 0.29 + 10000*0.37+(fe - 40000) * 0.45

    fo=fo/14
    fo=round(fo,2)
    return fo

s_ika=0
s_for=0
s_plir=0

mistos=open('d:/arxeia/salary.txt','r')
apotel=open("d:/arxeia/analysi.txt",'w')
for rec in mistos:
    rec=rec.strip()
    pedio=rec.split(",")
    am=int(pedio[0])
    epon=pedio[1]
    bm=float(pedio[2])
    wres=float(pedio[3])
    yperwr=yper(wres,bm)
    mikta,ikaer,ikaep,foreis=ypol_kr(bm,yperwr)
    ikaer=round(ikaer,2)
    ikaep = round(ikaep, 2)
    ika=round(ikaer+ikaep,2)
    foros=yp_forou(foreis)
    plir=round(mikta-ikaer-foros,2)
    s_ika +=ika
    s_for += foros
    s_plir +=plir
    gr="{},{},{},{},{},{},{},{},{}, {}\n".format(am,epon,bm,yperwr,mikta,ikaer,ikaep,ika,foros,plir)
    apotel.write(gr)

mistos.close()
print("Συνολο ΙΚΑ       :",s_ika)
print("Σύνολο Φόρου     :",s_for)
print("Σύνολο Πληρωτέου :",s_plir)