Results 1 to 14 of 14
Thread: Illegal Arithmetic Operations?
- 09-12-2008, 03:47 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 3
- Rep Power
- 0
Illegal Arithmetic Operations?
Hello,
I am currently teaching myself Java, and there is a question asking me in my book which of the following expressions are illegal:
2.3 * 1.2
5.67 - 2
25.0 / 5.0
7.0 % 3.0
8 % 2.0
But after re-reading everything, writing a program containing the expressions, and searching the internet, I have seen nothing wrong with these expressions.
Could someone point out something I am missing?
Thanks for your time.
- 09-12-2008, 05:20 AM #2
fire up your editor, enter them, and see what the compiler says.
- 09-12-2008, 02:04 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 3
- Rep Power
- 0
I already have, I guess this means they are all right?
- 09-12-2008, 02:17 PM #4
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
None of them is illegal
I die a little on the inside...
Every time I get shot.
- 09-12-2008, 06:00 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-12-2008, 08:14 PM #6
Member
- Join Date
- Sep 2008
- Posts
- 3
- Rep Power
- 0
The book said "State wether illegal or legal"
So I guess it might have been a trick question.
Thanks for the responses, I will be here to stay on the forums :D
- 09-12-2008, 11:05 PM #7
a more useful question is: do you get the expected answer.
Put some calls to System.out.println() in your code and see. I bet some will surprise you.
- 09-13-2008, 06:19 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-13-2008, 06:26 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-19-2008, 03:59 PM #10
Member
- Join Date
- Sep 2008
- Location
- Ankara-TURKEY
- Posts
- 42
- Rep Power
- 0
I think all of them are corret and my opinion is that dont spend too much time on those definitions.Good luck:D
A stitch in time saves nine:D
- 09-19-2008, 04:01 PM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
That is not a good opinion I think. Discovering new things make difference always.
- 09-19-2008, 04:32 PM #12
Member
- Join Date
- Sep 2008
- Location
- Ankara-TURKEY
- Posts
- 42
- Rep Power
- 0
"That is not a good opinion I think. Discovering new things make difference always. "
Yeah, you are right, discovering new things make difference always. And the only thing that we can not bring back is TIME.So, make things faster.
tOpach,
Kind regards.A stitch in time saves nine:D
- 09-19-2008, 04:37 PM #13
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
True, but what happen he/she is a newbie for such things. ;)
- 09-19-2008, 04:46 PM #14
Member
- Join Date
- Sep 2008
- Location
- Ankara-TURKEY
- Posts
- 42
- Rep Power
- 0
Similar Threads
-
HashMapTest.java uses unchecked or unsafe operations.
By jeer in forum New To JavaReplies: 22Last Post: 05-08-2008, 12:00 PM -
How to parse postfix arithmetic expressions
By Java Tip in forum java.langReplies: 0Last Post: 04-15-2008, 07:36 PM -
Stack push/pop/peek operations
By Java Tip in forum Java TipReplies: 0Last Post: 01-29-2008, 09:03 AM -
String operations..
By sireesha in forum New To JavaReplies: 4Last Post: 12-14-2007, 02:04 AM -
Uses unchecked or unsafe operations message
By Robbinz in forum New To JavaReplies: 2Last Post: 12-06-2007, 10:56 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks