We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
you can use predefined function of java i.e, Math.round(). Pass decimal value as parameter, it will return nearest integer or long value for given decimal number.
Example :
After all calculations your are supposed to get 15.36.
Now,
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
you can use predefined function of java i.e, Math.round(). Pass decimal value as parameter, it will return nearest integer or long value for given decimal number.
Example :
After all calculations your are supposed to get 15.36. Now,
int totalCost=Math.round(15.36);
totalCost=15.