I was solving some old exams of the first major exam in Java. I found this question which I don't really understand why did they use Ceil method in it. Also the qu开发者_如何学JAVAestion says "Parentheses are not allowed" what do they exactly mean they are not allowed?
This is the question:
the notation
around 93/10*x is ceiling function. Check out wikipediaEDIT:
ceiling is
floor is
See the difference?
The reason they used Math.ceil(...) in the Java portion is because of the partial brackets in the mathematical expression. Take a look at http://en.wikipedia.org/wiki/Floor_and_ceiling_functions for more information on mathematical expressions for floor and ceiling.
My guess as to why they didn't want you to use parentheses in the mathematical expression is that they should be extraneous. They were hinting that the parentheses in the Java language are for method calls and not part of the mathematical expression.
Parentheses are not allowed in the mathematical expression, that means, you were given the Java-Statement, not the other way round. Which means,
- you use fractions to avoid Paranthesis
- the Square-root-Symbol with a long line
- the
nx
- Notation forn*x
精彩评论