开发者

Arithmetic Expression

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:

Arithmetic Expression


the notation

Arithmetic Expression

around 93/10*x is ceiling function. Check out wikipedia

EDIT:

ceiling is

Arithmetic Expression

floor is

Arithmetic Expression

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 for n*x
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜