Advertisement
clrdz

Untitled

Mar 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package de.ostfalia.gdp.ss19.s1;
  2.  
  3. import java.util.Locale;
  4. import java.util.Scanner;
  5.  
  6. /**
  7. * Serie1
  8. *
  9. * @author Clarissa
  10. */
  11. public class Rechnung {
  12.  
  13. /**
  14. * main method
  15. *
  16. * @param args
  17. */
  18. public static void main(String[] args) {
  19.  
  20. Scanner scanner = new Scanner(System.in);
  21. scanner.useLocale(Locale.ENGLISH);
  22.  
  23. System.out.print("Menge(g):");
  24.  
  25. int menge = scanner.nextInt();
  26. System.out.print("Preis(Euro/Kg):");
  27.  
  28. double preis = scanner.nextDouble();
  29. scanner.close();
  30. System.out.println(); // für die Tests benötigt; bitte nicht entfernen
  31. // Ab hier sind Sie gefragt
  32.  
  33. double mengeInKG = (double) menge / 1000;
  34.  
  35. double rechnung = mengeInKG * preis;
  36.  
  37.  
  38. int euro = (int) rechnung;
  39. int cent = (int) (rechnung * 100 - euro * 100);
  40.  
  41. System.out.println("Ihre Rechnung hat eine Höhe von " + rechnung + "€");
  42. System.out.println("Gewicht = " + String.format("%10.2f",mengeInKG) + "kg");
  43. System.out.println("Euro = " + euro);
  44. System.out.println("Cent = " + cent);
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement