Rechner mit Oberon

S

Sven

Gast
Hallo.

Bin grad dabei Oberon zu lernen, bin zwar noch ziemlich am Anfang stehe aber bereits vor einem Problem.
Ich möchte eine Art Taschenrechner programmieren, der die Summe, das Produkt, die Differenz und den Quotienten von zwei Zahlen ausgibt.
Nur weiß ich jetzt nicht, wie ich die Ausgabe machen soll!
Das ist das bereits Fertige:

Code:
MODULE rechner;

IMPORT d:=Display;
VAR
 c:CHAR;
 x,y,s,p,di,div,mod:INTEGER;

PROCEDURE ProgMain*;
BEGIN
d.WriteStr("Gib zwei Zahlen ein!");
d.WriteLn;
d.WriteStr("Zahl 1: ");
d.ReadInt(x,3,c);
d.WriteLn;
d.WriteStr("zahl 2: ");
d.ReadInt(y,3,c);
s:=x+y;
di:=x-y;
p:=x*y;
div:=x DIV y;
mod:=x MOD y;
                  
  REPEAT UNTIL d.KeyPressed();
END ProgMain;
END rechner.
Ich hab die Ausgabe der Summe versucht mit
d.WriteInt(s) - das ging aber irgendwie nicht!

Hoffe, dass mir jemand helfen kann!
 
Display.WriteInt verlangt 2 Parameter. Am besten immer in OPAL nachschauen:
defined in module Display

Syntax

PROCEDURE WriteInt(x:LONGINT; len:INTEGER)

Description

The value contained in x is displayed at the current cursor position. The width of the output is len characters or more if this is necessary for the representation of the number. If a representation with len characters is possible the number is written right aligned. Then the cursor is moved to the end of the output.

Normalerweise setzt man für "len" immer "0" ein, in deinem Fall: d.WriteInt(s, 0);
 
Zurück
Oben