Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1.  
  2. public class RundenOhneMath {
  3.     public static int berechnung (double zahl){
  4.         int castInt = (int) zahl;
  5.         double zwischenergebnis = (zahl - castInt);
  6.         if (zwischenergebnis < 0.5)
  7.             return castInt;
  8.         else
  9.             return castInt+1;
  10.        
  11.     }
  12.     public static void main (String[] args){
  13.         Scanner sc = new Scanner (System.in);
  14.         System.out.println("Bitte zu rundende Zahl eingeben");
  15.         double inputDouble = sc.nextDouble();
  16.         int ergebnis = berechnung(inputDouble);
  17.         System.out.println(ergebnis);
  18.         sc.close();
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement