RE: Weird calculation
RE: Weird calculation
- Subject: RE: Weird calculation
- From: "Smith, Bradley" <email@hidden>
- Date: Thu, 24 Jan 2002 10:46:26 -0000
I would expect you division code to work but the rest won't because you need
break statements between each case statement like so: -
case 0:
loesung = wert1 + wert2;
break;
case 1:
loesung = wert1 - wert2;
break;
case 2:
loesung = wert1 * wert2;
break;
case 3:
loesung = wert1 / wert2;
break; // This one's not really necessary but I always do
one here as well.
Brad
>
-----Original Message-----
>
From: Thilo Ettelt [mailto:email@hidden]
>
Sent: 24 January 2002 10:24
>
To: email@hidden
>
Subject: Weird calculation
>
>
>
Hi!
>
>
I'm new to Cocoa and so I'm practising a bit. I wrote a little app,
>
which should give me the result of two values. The user can
>
select the
>
kind of calculation (+,-,*,/) via popupmenubutton.
>
>
That's the code of it's action:
>
>
--
>
>
float wert1, wert2, loesung;
>
>
wert1 = [value1 floatValue];
>
wert2 = [value2 floatValue];
>
>
switch([list indexOfSelectedItem]) {
>
case 0:
>
loesung = wert1 + wert2;
>
case 1:
>
loesung = wert1 - wert2;
>
case 2:
>
loesung = wert1 * wert2;
>
case 3:
>
loesung = wert1 / wert2;
>
}
>
>
[calc setFloatValue:loesung];
>
>
--
>
>
Please note that "loesung" stands for the result, "wert1" and "wert2"
>
for value 1 and 2. "calc" is the textfield for the result.
>
>
The strange thing (for me) is that I always get wrong results!
>
Can somebody help me?
>
>
>
Cheers, Thilo
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.