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

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); } }
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.