Autor Beitrag
KoPhi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 11.05.06 21:02 
Hi Leute,

habe ein kleines Problem

Aufgabe ist folgendermaßen:

...beträgt die Arbeitszeit im Betrieb weniger als 2 Jahre dann Prämie 1%.
...beträgt die Arbeitszeit im Betrieb max. 5 Jahre dann Prämie 2%.
...beträgt die Arbeitszeit im Betrieb länger als 5 Jahre dann Prämie 3%.

---

Meine IF-Funktionen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
IF arbeitszeit<2
then brutto:=grundlohn/100*101;
IF arbeitszeit<=5
then brutto:=grundlohn/100*102;
IF arbeitszeit>5
then brutto:=grundlohn/100*103;


---

Das Problem, wenn ich 1 Jahr Arbeitszeit eingebe nimmt er auch 2%...

Was ist falsch?

Gruß KoPhi

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 11.05.06 21:06 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
IF arbeitszeit < 2 then 
  brutto:=grundlohn/100*101
  else
    IF arbeitszeit <= 5 then 
      brutto:=grundlohn/100*102
      else 
        IF arbeitszeit > 5 then
          brutto:=grundlohn/100*103;


Oder halt Abfragen wie

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
IF arbeitszeit<2
then brutto:=grundlohn/100*101;
IF (arbeitszeit <= 5AND (arbeitszeit >= 2)
then brutto:=grundlohn/100*102;
IF arbeitszeit>5
then brutto:=grundlohn/100*103;

_________________
We are, we were and will not be.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 11.05.06 21:06 
Die Abfragen werde nacheinander abgearbeitet.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
IF arbeitszeit<2
then brutto:=grundlohn/100*101;
IF arbeitszeit<=5
then brutto:=grundlohn/100*102;
IF arbeitszeit>5
then brutto:=grundlohn/100*103;

Der markierte Teil trifft ja dann auch zu, und es kommt zwei raus. Ist logisch oder? :zwinker:

Besser so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
IF arbeitszeit<2
then brutto:=grundlohn/100*101
ELSE IF arbeitszeit<=5
then brutto:=grundlohn/100*102
Else brutto:=grundlohn/100*103;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
KoPhi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 11.05.06 21:11 
Dankeschön an euch beide!

Es funktioniert jetzt und ich habe es kapiert! :D

Toller Service! Innerhalb 4 Minuten 2 Antworten!


Thx

Gruß KoPhi