(5 + 6) / 2 = ?
Here is my code to calculate the expression (5 + 6) / 2:
public class Trytosee
public static void main(String[] args)
double x;
x = (5 + 6) / 2;
System.out.println(x);
I got the result from the output Screen: 5.0. I wonder why not 5.5? Could somebody help?
To further elaborate:
(5 + 6) / 2 gives the integer result of 5 which is cast to 5.0 when it is assigned to the double variable x. If you wish to have the result 5.5 stored then you need to change one of the values to float.
x = (5 + 6) / 2.0;
Similar Messages
Maybe you are looking for
-
DVD not downloading full length
I am trying to download a 2-hour DVD to iMovie but only 1.51 minutes download. Suggestions?
-
Funds Transfer from one house bank to another house bank
Hi How to transfer funds from one house bank to another house bank with in company code. Because i want to transfer funds from one house bank to another house bank. What are the steps required . Please let me know the same Regards ram
-
Crystal Report in V.b 6.0
Hi Expert, Can anybody give me sample coding of crystal report whcih i call in v.b 6.0 program by using parameter.
-
Invalid session id when logging in after logging out.(Stale session token?)
When I logout and then login again I get an exception in the agent debug log which seems to indicate that it is trying to use the old session token. The agent is correctly seeing the logout event and redirecting to the logout page and then to the log
-
How can I change my security questions? I forgot my passwords
I was wondering if I can change my security questions because I forgot my passwords to them.