Römische Zahlen

MODULE Rom;

IMPORT Display;

PROCEDURE ProgMain*;
VAR zahl: INTEGER; ch:CHAR;

BEGIN

       Display. WriteStr ("UMRECHNUNG DEZIMAL ->= RÖMISCH");
       Display. WriteLn;

       Display. WriteStr ("Bitte Zahl eingeben: ");
       Display. ReadInt (zahl, 5, ch);
       Display. WriteLn;

       WHILE zahl >= 1000 DO
              Display. WriteStr ("M");
              zahl:=zahl-1000;
       END;

       IF zahl >= 900 THEN
              Display. WriteStr ("CM");
              zahl:=zahl-900;
       END;

       IF zahl >= 500 THEN
              Display. WriteStr ("D");
              zahl:=zahl-500;
       END;

       IF zahl >= 400 THEN
              Display. WriteStr ("CD");
              zahl:=zahl-400;
       END;

       WHILE zahl >= 100 DO
              Display. WriteStr ("C");
              zahl:=zahl-100;
       END;

       IF zahl >= 90 THEN
              Display. WriteStr ("XC");
              zahl:=zahl-90;
       END;

       IF zahl >= 50 THEN
              Display. WriteStr ("L");
              zahl:=zahl-50;
       END;

       IF zahl >= 40 THEN
              Display. WriteStr ("XL");
              zahl:=zahl-40;
       END;

       WHILE zahl >= 10 DO
              Display. WriteStr ("X");
              zahl:=zahl-10;
       END;


       IF zahl = 9 THEN
              Display. WriteStr ("IX");
              zahl:=zahl-9;
       END;

       IF zahl >= 5 THEN
              Display. WriteStr ("V");
              zahl:=zahl-5;
       END;

       IF zahl = 4 THEN
              Display. WriteStr ("IV");
              zahl:=zahl-4;
       END;

       WHILE zahl >= 1 DO
              Display. WriteStr ("I");
              zahl:=zahl-1
       END;
       Display. WriteLn;
       REPEAT UNTIL Display.KeyPressed();
END ProgMain;

END Rom.


Zurück zur Übersicht über die Wiederholung mit Anfangsbedingung