Mohammad Fadin
Mohammad Fadin

Reputation: 579

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 question says "Parentheses are not allowed" what do they exactly mean they are not allowed?

This is the question:

enter image description here

Upvotes: 1

Views: 1516

Answers (3)

user unknown
user unknown

Reputation: 36229

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

Upvotes: 0

Bala R
Bala R

Reputation: 108937

the notation enter image description here around 93/10*x is ceiling function. Check out wikipedia

EDIT:

ceiling is enter image description here

floor is enter image description here

See the difference?

Upvotes: 3

Norman
Norman

Reputation: 31

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.

Upvotes: 0

Related Questions