SortDouble.java 710 B

123456789101112131415161718
  1. import static java.lang.Math.*; // macht Methoden von Math bekannt
  2. public class SortDouble
  3. {
  4. public static void main(String[] args) throws
  5. Exception
  6. {
  7. InteractiveIO.write("Dieses Programm sortiert drei Zahlen.");
  8. double a = InteractiveIO.promptForDouble("Bitte erste Zahl eingeben: ");
  9. double b = InteractiveIO.promptForDouble("Bitte zweite Zahl eingeben: ");
  10. double c = InteractiveIO.promptForDouble("Bitte dritte Zahl eingeben: ");
  11. double min = min(a, min(b, c));
  12. double max = max(a, max( b, c));
  13. double mid =a + b + c - min - max;
  14. InteractiveIO.write("Sortiert: " + min + " " + mid + " " + max);
  15. }
  16. }