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...

View Answers

February 24, 2011 at 2:02 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); 
    }
}









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
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">
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
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
SQL ROUND Function
SQL ROUND Function       Round Function in SQL is used to round a numeric field to the nearest... illustrates an example from SQL Round Function. In this Tutorial, we create
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
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
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   using a function to find the value of v from the foiiowing expression 1v=1u+1*f
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
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
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
MySQL Round
; ROUND() function of MySQL rounds the number to the upwards or downwards... rounded number ROUND() function uses "round half up". "round half... is optional. Explanation: Suppose we apply the ROUND() function on the positive integer
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
messages to the screen without using "document.write()"
messages to the screen without using "document.write()"  To write messages to the screen without using "document.write
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
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
multiple form with multiple function in 1 jsp - JSP-Servlet
multiple form with multiple function in 1 jsp  Hi, I'm using Netbean... each form to call several function when user click buttons of these forms...) { top.location.href="signup.jsp" } function clear
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
multiple JComboBoxes using with JDBC
multiple JComboBoxes using with JDBC  how to use JComboBoxes with JDBC in java  Hi Friend,Try the following code:import java.awt.*;import java.sql.*;import javax.swing.*;public class MultipleJCombo{public MultipleJCombo
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
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
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
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
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
Multiple image upload using JSP
Multiple image upload using JSP  I have written a code to upload the multiple images using jsp, but when I execute this code, it throws Corrupt form... type="file" name="file[]" multiple > <INPUT type="submit" value="Send
Uploading Multiple Files Using Jsp
Uploading Multiple Files Using Jsp  ... to understand how you can upload multiple files by using the Jsp. We should avoid... a file. In this example we are going to tell you how we can upload multiple files
Multiple buttons in struts using java script
Multiple buttons in struts using java script  Multiple buttons in struts using java script
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
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
Breaking a string into words without using StringTokenizer
Breaking a string into words without using StringTokenizer  how can we Break a string into words without using StringTokenizer ??   The given code convert the string into words. import java.util.*; class StringExample
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
String length without using length() method in java
String length without using length() method in java  How to count length of string without using length() method in java?   Here is Example... the number of character into the given string without using the length() method
send without authentication mail using java - JavaMail
send without authentication mail using java  Dear All, I am tring to send simple mail without authentication using java. is it possible, could i send email without authentication. I have written following code. public
Storing Multiple image in sql using java
Storing Multiple image in sql using java  Hi, How to store and retrieve a multiple image in sql using java but already i have created sql table if i want to insert a image while runtime execution. Can anyone tell me solution
Round the Decimal values
Round the Decimal values  How to round the decimal value with out using Math.round() Example:round the 2.7 as a 3.0 round the 2.4 as a 2.0
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new... there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. plz let me know
how to convert string to char array in java without using tochararray
() function. how to convert string to char array in java without using...how to convert string to char array in java without using tochararray ... to char array in java without using tochararray: package my.app; public
Multiple inheritance using interface - Java Beginners
Multiple inheritance using interface  Hi, I understand.... But the use of the interface is when we use multiple inheritance with more than one... in multiple inheritance Thank you, Rajkanth  Hi Friend, Please
inserting multiple file formats into database using html
inserting multiple file formats into database using html   hi the code was working fine,i want to choose the file and then upload to database,by using html.whether it is possible to upload larger file size,please explain
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
how to delete a row in sql without using delete command.
how to delete a row in sql without using delete command.  how to delete a row in sql without using delete command. thanks in advance
how to validate the telephone number without using jquery in html with javascript
how to validate the telephone number without using jquery in html with javascript  how to validate the telephone number without using jquery in html with javascript

Ads