Autor Beitrag
Soccerkati
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 27.03.06 19:30 
habe folgendes problem.
habe ein fehler in meinem quelltext.
problem ist : wenn der user eine negative wärmekapazität eingibt (z.b. Q=-20), so darf/muss auch die temperaturdifferenz Te-Ta negativ sein.
Ist Q positiv so darf die temperaturdifferenz Te-Ta nicht negativ sein.
und wenn ist Q negativ ist , darf die temperaturdifferenz Te-Ta nicht positiv sein.
das muss ich definieren,aber ich krieg das irgendwie nicht hin.jemand eine idee?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
var m,Q,c,Te,Ta: real;
i: integer;

begin
i:=combobox1_m.itemindex;

m := StrToFloat(Edit1_Masse.Text);
  case i of
    0: m := m;
    1: m := m*1000;    // kg
    2: m := m*1000000; // t
    3: m := m/1000;    // mg

end;


i:=combobox1_Q.itemindex;

Q := StrToFloat (Edit1_menge.Text);
  case i of
    0: Q := Q;
    1: Q := Q/1000;    // KJ
    2: Q := Q/1000000; // MJ

end;

i:=combobox1_Ta.itemindex;

Ta := StrToFloat (Edit1_anfang.Text);
  case i of
    0: Ta := Ta;
    1: Ta := Ta-273;    // °C

end;

i:=combobox1_Te.itemindex;

Te := StrToFloat (Edit1_ende.Text);
  case i of
    0: Te := Te;
    1: Te := Te-273;    // °C

end;
         if (m*(Te-Ta))<>0
         then
                begin
                c:=Q/(m*(Te-Ta));
                edit1_ausgabe.Text:=floattostr(c);
                end
         else
                begin
                edit1_ausgabe.Text:='nicht lösbar';
                end;

        if Q=0
        then
        edit1_ausgabe.Text:='0';

        if (m*(te-ta))>0
        then
                begin
                c:=Q/(m*(Te-Ta));
                edit1_ausgabe.Text:=floattostr(c);
                end
        else
                begin
                edit1_ausgabe.Text:='nicht lösbar';
                end;

        if m<0
        then
        edit1_ausgabe.Text:='nicht lösbar';

        if Q<0 and (te-ta)<0     [<--- funktioniert nicht]        
        then
                begin
                c:=Q/(m*(Te-Ta));
                edit1_ausgabe.Text:=floattostr(c);
                end
        else
                begin
                edit1_ausgabe.Text:='nicht lösbar';
                end;

end;


Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 19:37 
hallo,

setze 1. bitte delphi tags mit {delphi} code {/delphi} - statt den geschweiften klammern natürlich eckige ;)

2. musst du bei if abfragen, bei denen du and, xor, or verwendest, klammern setzen ;)
folglich muss dein code so aussehen
ausblenden Delphi-Quelltext
1:
2:
3:
if (Q<0) and ((te-ta)<0) then
 begin
  ...



mfg, marc


Zuletzt bearbeitet von Marc. am Mo 27.03.06 19:41, insgesamt 2-mal bearbeitet
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 27.03.06 19:38 
Da muss man klammern:

ausblenden Delphi-Quelltext
1:
 if (Q<0) and ((te-ta)<0)					

_________________
We are, we were and will not be.
Soccerkati Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 27.03.06 19:41 
danke ich probier mal aus

hihi danke geht :)
so ein kleiner fehler
Soccerkati Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 27.03.06 19:47 
habe noch ein kleines problem.
mein gesamtes programm heißt "programm".
ich will das in waermekapazitaet umwandeln.
wie mach ich das am besten?weil wenn ich mach "save project as" und einen neuen órdner mach etc...dann speichert der da keine exe rein?
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 27.03.06 19:50 
speicher's in nen neuen ordner und kompilier dann nochma (auf den grünen startpfeil drücken), dann haste ne exe...
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 19:50 
den pfad, in der du die exe speicherst, legst du unter Project -> Options -> Directiories fest ;)
Über Project -> Build Project erzeugst du deine exe ;)
Soccerkati Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Mo 27.03.06 20:12 
mein ergbenis hat mir zu viele dezimalstellen nach dem komma.
wie definiert man das?also das muss in die formel rein ne?vrhältnis 5:2 auf 2 kommastellen nach dem komma?
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 27.03.06 20:25 
runden kannst du mit "RoundTo()"; ;)
ausblenden Delphi-Quelltext
1:
 edit1_ausgabe.Text:= := FloatToStr(RoundTo(C,-2)); // -2 um auf 2 nachkommastellen zu runden					

Und nicht vergessen "Math" in die uses-klausel einzubinden! ;)

mfg, Marc