请教如何用一条STATEMENT 求出ROUNDPRODUCT, 谢了!!
We want to develop an app that starts with two positive integers, computes their product,
and then computes and outputs the average of the product and the product rounded up to
the nearest multiple of 5. For example, if the two numbers are 4 and 8, then their product
is 32, and their product rounded up to the nearest multiple of 5 is 35. The app must thus
output the average of 32 and 35, which is (32+35)/2 or 33.5. Note that if the product is
already positive then it is not changed; e.g. if the two numbers were 3 and 5 then the output
would be 15.0.
The sought app is shown below:
import type.lang.*;
public class Check02B
{ public static void main(String[] args)
{ //----------------------------------Declare
final int ROUNDING_BASE = 5;
long first, second;
long product, roundedProduct;
double average;
//----------------------------------Init
first = 762;
second = 56;
//----------------------------------Compute
product = ???
roundedProduct = ???
average = ???
//----------------------------------Output
IO.println(average);
}
}
You need to complete the compute section by replacing "???" by arithmetic expressions.
You may not add or remove statements; the compute section should contain the above
three statements only
请JAVA高手帮忙, 有一逻辑问题请教!
所有跟帖:
•
((round((product+ROUNDING_BASE
-lidongmei-
♂
(54 bytes)
()
01/15/2005 postreply
12:17:27
•
谢谢!但还有问题
-求助求助!!!-
♀
(136 bytes)
()
01/16/2005 postreply
09:58:38
•
(Math.round((product+ROUNDING_
-lidongmei-
♂
(71 bytes)
()
01/16/2005 postreply
18:32:53
•
不错,就是这样能用了, 谢谢!!
-求助求助!!!-
♀
(0 bytes)
()
01/16/2005 postreply
19:07:27
•
回复:不错,就是这样能用了, 谢谢!!
-NewYoker-
♂
(0 bytes)
()
01/16/2005 postreply
20:02:23
•
回复:不错,就是这样能用了, 谢谢!!
-NewYoker-
♂
(0 bytes)
()
01/16/2005 postreply
20:03:40
•
first*second/5*5
-junkmaker-
♂
(0 bytes)
()
01/16/2005 postreply
20:11:44
•
the best than
-junkmaker-
♂
(0 bytes)
()
01/16/2005 postreply
20:14:56
•
best answer
-junkmaker-
♂
(32 bytes)
()
01/16/2005 postreply
20:22:39