Hey guys!
I am starting with a course on school with lazarus. But I am kind of stuck at the moment.
I should create a very basic calculator. I need to insert a number, do an operation (+,-,*,/) insert another number, a new operation and so on. Until I press '='.
After '=' the result should be shown. The operations should be in sequence and not so much as in the normal rules of math! I hope someone can help me out with this. I already have a part of the code, but can't to figure it out well.
program NieuwRekenmachine;
var
{ TODO: check and accomplish variable declarations }
uitkomst: Single;
keuze: string;
getalB: Longint;
getalA: Longint;
begin
uitkomst := 0;
writeln('Geef Een getal');
readln(getalA);
while (keuze<>'=') do
begin
writeln('+');
writeln('-');
writeln('*');
writeln('/');
writeln('=');
readln(keuze);
writeln('Geef een getal');
readln(getalB);
case (keuze) of
'+':
begin
uitkomst := getalA+getalB;
end;
'-':
begin
uitkomst := getalA-getalB;
end;
'*':
begin
uitkomst := getalA*getalB;
end;
'/':
begin
uitkomst := getalA/getalB;
end;
else
writeln('Niet geldig');
end;
end;
if (keuze<>'=') then
begin
writeln('de uitkomst bedraagt:', uitkomst:0:2);
end;
writeln;
writeln('Druk op <ENTER> om het programma te sluiten.');
readln();
end.