fork download
  1. import java.util.Scanner;
  2. class Ideone{
  3. public static void main (String[] args){
  4. Scanner input = new Scanner(System.in);
  5. int x=input.nextInt(),y=input.nextInt();
  6. int floor, ceil, round;
  7. float z=((float)x/y)-x/y;
  8. if(z<0.5&&z>0.0){
  9. floor=x/y;
  10. ceil=x/y+1;
  11. round=x/y;
  12. }
  13. else if(z==0.0){
  14. floor=x/y;
  15. ceil=x/y;
  16. round=x/y;
  17. }
  18. else{
  19. floor=x/y;
  20. ceil=x/y+1;
  21. round=x/y+1;
  22. }
  23. System.out.println("floor "+x+" / "+y+" = "+floor);
  24. System.out.println("ceil "+x+" / "+y+" = "+ceil);
  25. System.out.println("round "+x+" / "+y+" = "+round);
  26. }
  27. }
Success #stdin #stdout 0.18s 60940KB
stdin
10 3
stdout
floor 10 / 3 = 3
ceil 10 / 3 = 4
round 10 / 3 = 3