write a program which accepts three integers as command line arguments.Round each number to the next multiple of 10,If the right most digit is 5 or more,otherwise round it down to previous multiple of 10.

For example: 15 and 17 round up to 20 where as 12 round up to 10.

calculate and print the sum of these rounded values.

tell me logic if you know

December 20th, 2013, 01:51 AM

GregBrannon

Re: java rounded sum

You tell us first.

December 20th, 2013, 02:07 AM

andbin

Re: java rounded sum

Quote:

Originally Posted by harvind

tell me logic if you know

First, command line arguments are String values. Do you know how to parse (convert) a String into an int?
Second, in the Java SE framework there is no method to "round" a number at multiples of the unit (eg. 10, 100 etc..). There are rounding methods in Math class but they round at decimals level. The rounding at multiples of 10 is up to you and there is more than one possibility. All you need are the standard operators / % +. Eventually with a test using an if.