function class(am,uc,ra,us) { if (am >= 3) return 5 if ( (uc >= 2) && (us <= 1) ) return 5 if ((uc >= 2) && (am <= 1) && (us <= 2) )return 5 if ((ra >= 4) && (us >= 3) ) return 4 if ((am <= 1) && (us >= 2) && (us <= 2)) return 4 if (us <= 1) return 3 if ((ra >= 3) && (ra <= 3)) return 3 return 1.5 } BEGIN { OFS="\t" print "#am","#uc","#ra","#us","#class"; for(ra=1;ra<=5;ra++) for(us=1;us<=5;us++) { am=2 uc=3 print am,uc,ra,us,class(am,uc,ra,us) } }