English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

These are the possible answers 1, 8, 17, 21. Could possibly explain how and why as well. Thanks.

2007-05-31 04:48:46 · 8 answers · asked by Will E 2 in Computers & Internet Programming & Design

I don't understand the difference between a backslash and a forward slash.

2007-05-31 04:53:29 · update #1

8 answers

You should think about what types the numbers are. Once you consider that, it is easy. You aren't cheating are you?

2007-05-31 04:51:49 · answer #1 · answered by Anonymous · 0 1

Since the division has a higher operator precedence than the addition your expression is equivalent to 8 + (7 / 2) + 10. Therefore the answer is 21.

2007-05-31 05:10:43 · answer #2 · answered by Lewis W 1 · 0 0

This goes back to algebra and the order in which operations take place in an equation. Remember: Please Excuse My Dear Aunt Sallie?

the above will evaluate as 8+3.5+10 making the answer 21.5. If you were to enclose the 8 + 7 and the 2 + 10 in parenthases you would get (8+7)/(2+10) which is 1.25.

2007-05-31 05:05:48 · answer #3 · answered by Anonymous · 0 0

Believe that java would do the math from left to right. It would add 8 and 7 (15), then divide by 2 (7), then add 10, giving the answer 17.

2007-05-31 04:53:54 · answer #4 · answered by dewcoons 7 · 0 2

Java follows the standard international rules about division and adding (first multplication/division then adding/substracting), so java reads it as 8 + (7/2) +10 = 21. (offcourse, if you are working with floats, it is 21.5 :)

2007-05-31 04:57:21 · answer #5 · answered by Ampy 2 · 0 0

If you are doing integer math, it's 21 because division takes precedence (meaning it's done first) then the additions are performed. If it's floating point math then your answer is 21.5

2007-05-31 05:00:01 · answer #6 · answered by SHAWN G 3 · 0 0

it does not work the same way they teach you in algebra.
15/2=7.5
17.5 which it would cut I assume to just 17 beacuse it would most likey be a fixed varable (not floating)

2007-05-31 04:52:38 · answer #7 · answered by zspace101 5 · 0 2

best way to do something like this is to actually do it
get an ide and run the code, that way you can be sure.

2007-05-31 05:03:30 · answer #8 · answered by outbaksean 4 · 0 0

fedest.com, questions and answers