Round of to a multiple of 5 without using function

Ads
 

Round of to a multiple of 5 without using function

Please help me out...

U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively...

View Answers

February 24, 2011 at 2:01 PM

import java.io.*;
class RoundTo5Multiplicant 
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 
        String a=br.readLine();
        int num=Integer.parseInt(a);
        int div=num%5;
        if(div<=2)
            num-=div;
        else if(div>2)
            num+=(5-div);
        System.out.println("The final result is: "+num); 
    }
}

Ads









Related Tutorials/Questions & Answers:
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Advertisements
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
Program to Find Cube Root of any Number without using built in function
Program to Find Cube Root of any Number without using built in function  Please help me in finding cube root of any number without using Built in function in java
refreshing a jsp without flickering effect for every 5 seconds using ajax
refreshing a jsp without flickering effect for every 5 seconds using ajax  I want to refresh a jsp without flickering for every 5 seconds using..." CONTENT="5"> <html> <head> <script type="text/javascript">
SQL ROUND Function
SQL ROUND Function       Round Function in SQL is used to round a numeric field to the nearest... SQL Round Function. In this Tutorial, we create a table 'Stu_Table'. 
Multiple files upload code using spring mvc 2.0 with xml configuration without using annotations
Multiple files upload code using spring mvc 2.0 with xml configuration without using annotations  how to write code to attach multiple files and upload using spring mvc 2.o with xml configuration with out annotations? please
SQL ROUND Function
SQL ROUND Function       Round Function in SQL is used to round a numeric field to the nearest... an example from SQL Round Function. In this Tutorial, we create a table 'Stu_Table
i want to select a multiple value of check box by using onclick or onchange event without using from submission
i want to select a multiple value of check box by using onclick or onchange event without using from submission   i have 4 check box name 1)profile 2)commercial 3)motion 4)personal and 4 radio button name 1)500-1000 2
using function
using function   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
Pagination without using database in php
Pagination without using database in php  How can I show multiple images in multiple rows with pagination in php
using function
using function  write a program using function overloading to accept any sentence and print vowels and consonants sepratly   Here is an example that accepts a sentence from the user and display the vowels and consonants
Add year to Date without using Calendar in java
Add year to Date without using Calendar in java  how could i add a year to a date function without using calendar functions
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
using tiles without struts
using tiles without struts  Hi I am trying to make an application using tiles 2.0. Description of my web.xml is as follows: tiles org.apache.tiles.web.startup.TilesServlet
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
Using criteria for multiple tables
Using criteria for multiple tables  How to join more than three tables,those tables must be maintain primary key relation ship using Hql criteria & projections
MySQL Round
; ROUND() function of MySQL rounds the number to the upwards or downwards... rounded number ROUND() function uses "round half up". "round half...: Suppose we apply the ROUND() function on the positive integer value 123.34
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
Sorting arraylist without using Collection.sort()
Sorting arraylist without using Collection.sort()  Hi, How can I sort an arraylist without using Collection.sort() nad also I am not allowed to use any other data structure in the program? Is there any algorithm by using which I
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
Email to multiple recipients using jsp
Email to multiple recipients using jsp  Hi sir, Am a doing a project,in that i need to send email to multiple user at a time,the to address should enter manually its not not be written in code using jsp. Regards, Santhosh
multiplication function in jsp using scriptlet function
multiplication function in jsp using scriptlet function   how...">--> <script type="text/javascript"> function txtnull...; if(a=="") { alert("insert data"); } } function sum(txt
validation of strings using java function
validation of strings using java function  hi all, i am uploading data from csv file to data base where i took student id as string of length 6 char of the form abc123 will you please give me a function to validate this field
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
sum and avg function using HQL.
sum and avg function using HQL.  How to use sum and avg function... of them. sum() function returns summation of specified field in the table. avg() function returns average of specified field in the table. Example
Java repeat string without using loops
Java repeat string without using loops In this section, you will learn how to repeat string without using for loops. The given example accepts the number of times and iterates the string to the number of times set by the user without
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using checkbox   We are providing you the code where we have specified only three fields bookid,author and title in the database. 1) Create book.jsp <%@page

Ads