| Kertotaulu.java |
1 import java.io.*;
2 /**
3 * Ohjelmalla tulostetaan kertotaulu tiedostoon. Jos tiedosto on
4 * olemassa, jatketaan vanhan tiedoston perään.
5 * @author Vesa Lappalainen
6 * @version 1.0, 21.02.2003
7 */
8 public class Kertotaulu {
9
10 public static void main(String[] args) {
11 PrintStream fo = null;
12 try {
13 fo = new PrintStream(new FileOutputStream("taulu.txt",true));
14 } catch (FileNotFoundException ex) {
15 System.out.println("Tiedosto ei aukea"); return;
16 }
17
18 int kerroin = 5;
19
20 try {
21 for (int i=0; i<10; i++)
22 fo.println( i + "*" + kerroin + " = " + i*kerroin);
23 } finally {
24 fo.close();
25 }
26 }
27 }
28 | Kertotaulu.java |