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]; } } };
Fr Jul 30 13:54:24 CEST 2021
patent_button.gif valid-html401.png elektra.jpg fsfe-logo.png valid-css.png vim.gif anybrowser.gif