import java.io.*; import java.util.StringTokenizer; public class buss{ public static void main(String argumendid[]) throws IOException{ String[] peatused=new String[200]; String[] ajadt=new String[200]; String[] ajadm=new String[200]; String kokku=""; BufferedReader sisse=new BufferedReader( new FileReader("peatused.txt") ); String rida=sisse.readLine(); int x=0; int pikk=0; while(rida!=null){ StringTokenizer st=new StringTokenizer(rida, " ."); while(st.hasMoreTokens()){ String nimi=st.nextToken(); peatused[x]=nimi; String aegt=st.nextToken(); ajadt[x]=aegt; String aegm=st.nextToken(); ajadm[x]=aegm; pikk=x; x++; } rida=sisse.readLine(); } BufferedReader sisse2=new BufferedReader( new FileReader("algus.txt") ); String rida2=sisse2.readLine(); while(rida2!=null){ StringTokenizer st2=new StringTokenizer(rida2, ". "); while(st2.hasMoreTokens()){ int t=Integer.parseInt(st2.nextToken()); int m=Integer.parseInt(st2.nextToken()); for(int y=0; y<=pikk; y++){ int ajm=Integer.valueOf(ajadm[y]).intValue(); int ajt=Integer.valueOf(ajadt[y]).intValue(); System.out.println(t+" "+m+" "+ajm+" "+ajt); if(m+ajm>60){ m=(m+ajm)-60; t=t+1+ajt; } else{ m=m+ajm; t=t+ajt; } kokku=kokku+peatused[y]+" "+t+"."+m+", "; } kokku=kokku+"\n"; } rida2=sisse2.readLine(); } PrintWriter faili=new PrintWriter( new FileWriter("bussid.txt") ); faili.println(kokku); faili.close(); System.out.println("valmis"); } }