This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / 请问如何将下列JAVA语句用一句JAVA表达式改写,只用一句,尽量短if x>=1000
y = ( x - 1000)*0.05;
else if x>=1500
y = y + (x-1500)*0.05;
else if x>=3000
y = y + (x-3000)*0.05;
else
y = 0;
-writesome(penwrite);
2003-9-3
{152}
(#1354791@0)
-
You can use ? : to do that.
-deepblue(Shopping...);
2003-9-3
(#1354846@0)
-
我知道这个啊,但具体怎么用啊,谢谢
-writesome(penwrite);
2003-9-3
(#1354867@0)
-
this is JAVA Code?my god.
-guestagain(guest again);
2003-9-3
(#1355016@0)
-
y=x<1000?0:(x-1000)*0.05;
-xiaoxiao(笑笑);
2003-9-3
(#1355041@0)
-
like this: y = (x >= 1000)?(x - 1000)*.05:0
-agentkiller(key);
2003-9-3
(#1355044@0)
-
你的逻辑有问题。:))))))
-oxknife(闲人 LUCKY@2003);
2003-9-3
(#1355394@0)
-
我也觉得奇怪啊!
-m30(m30);
2003-9-3
(#1355726@0)
-
agree.:-)
-henhen(哼哼, 找工ing ^_^);
2003-9-3
(#1355729@0)
-
你牛啊你!Offer就给你了,明天就来上班。
-m30(m30);
2003-9-3
(#1355733@0)
-
how about you?
-henhen(哼哼, 找工ing ^_^);
2003-9-3
(#1355739@0)
-
it's just a trick
-agentkiller(key);
2003-9-3
(#1355766@0)
-
对不起,我搞错了,原程序应该是这样的,见内int x;
double y;
if (x>=1000)
if (x>=1500)
if (x>=3000)
y= (x-1000)*0.05 + (x-1500)*0.05 +(x-3000)*0.05;
else
y= (x-1000)*0.05 + (x-1500)*0.05;
else
y = (x-1000)*0.05;
else
y = 0.00;
-writesome(penwrite);
2003-9-3
{235}
(#1356048@0)
-
如果这是找java工作的测试题,这java市场也就快完蛋了
-eglington(eglington);
2003-9-4
(#1356053@0)
-
那您知道怎么用一句JAVA表达式改写以上语句吗?
-writesome(penwrite);
2003-9-4
(#1356064@0)
-
作为一个10年老IT,惭愧,我不会
-eglington(eglington);
2003-9-4
(#1356094@0)
-
y = ( (x>=1000) ? ((x-1000)*0.05) : 0 ) + ( (x>=1500) ? ((x-1500)*0.05) : 0 ) + ( (x>=3000) ? ((x-3000)*0.05) : 0 )
-xhis(枫下恩仇#13 xhis);
2003-9-4
(#1356084@0)
-
谢谢啦,偶太笨了
-writesome(penwrite);
2003-9-4
(#1356096@0)