Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RundenOhneMath {
- public static int berechnung (double zahl){
- int castInt = (int) zahl;
- double zwischenergebnis = (zahl - castInt);
- if (zwischenergebnis < 0.5)
- return castInt;
- else
- return castInt+1;
- }
- public static void main (String[] args){
- Scanner sc = new Scanner (System.in);
- System.out.println("Bitte zu rundende Zahl eingeben");
- double inputDouble = sc.nextDouble();
- int ergebnis = berechnung(inputDouble);
- System.out.println(ergebnis);
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement