import eprog.*; public class Geld { public static void main (String [] arg) { int geld; int [] werte = {50000,20000,10000,5000,2000,1000,500,200,100,50,20,10,5,2,1}; try { EprogIO.print ("Geld (Euro,Cent): "); geld = (int) (EprogIO.readDouble () * 100); } catch (Exception e) { EprogIO.print("Ungültigen Betrag eingegeben!"); return; } for (int i =0; i< werte.length; i++) { while (geld > 0) { geld -= werte[i]; if (geld >= 0) if (werte[i] < 100) EprogIO.println (werte[i] + " Cent"); else EprogIO.println (werte[i] / 100 + " Euro"); if (geld == 0) return; // exaktes Ergebnis erreicht } if (geld < 0) geld += werte[i]; } } };
Archiviert am 14.02.2026
valid-html401.png patent_button.gif anybrowser.gif permaplant.png vim.gif elektra.jpg fsfe-logo.png valid-css.png