Add README.md
[pdp8.git] / sw / src / pascal / ZAHLWO.PS
CommitLineData
81e70d48
PH
1PROGRAM ZAHLWOERTER(INPUT,OUTPUT);
2
3 VAR N: INTEGER;
4
5 PROCEDURE EINER(E: INTEGER);
6 BEGIN CASE E OF
7 1: WRITE("EIN");
8 2: WRITE("ZWEI");
9 3: WRITE("DREI");
10 4: WRITE("VIER");
11 5: WRITE("FUENF");
12 6: WRITE("SECHS");
13 7: WRITE("SIEBEN");
14 8: WRITE("ACHT");
15 9: WRITE("NEUN");
16 10: WRITE("ZEHN");
17 11: WRITE("ELF");
18 12: WRITE("ZWOELF");
19 END
20 END (* EINER *);
21
22 PROCEDURE ZEHNER(Z: INTEGER);
23 BEGIN CASE Z OF
24 1: WRITE("ZEHN");
25 2: WRITE("ZWANZIG");
26 3: WRITE("DREISSIG");
27 4: WRITE("VIERZIG");
28 5: WRITE("FUENFZIG");
29 6: WRITE("SECHZIG");
30 7: WRITE("SIEBZIG");
31 8: WRITE("ACHTZIG");
32 9: WRITE("NEUNZIG")
33 END
34 END (* ZEHNER *);
35
36
37BEGIN READLN;
38 WHILE NOT EOF DO
39 BEGIN
40 READ(N); WRITE("ZAHL:",N:5," WORT: ");
41 IF N=1
42 THEN WRITE("EINS")
43 ELSE IF N<=12
44 THEN EINER(N)
45 ELSE IF N<=19
46 THEN BEGIN EINER(N-10);WRITE("ZEHN") END
47 ELSE IF N MOD 10 = 0
48 THEN ZEHNER(N DIV 10)
49 ELSE BEGIN EINER(N MOD 10);
50 WRITE("UND");
51 ZEHNER(N DIV 10)
52 END;
53 WRITELN
54 END
55END.