123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class ZahlSumme
- {
- public static void main(String[] args) throws Exception
- {
- int sum = 0;
- String zw = InteractiveIO.promptAndRead("Zahlwort bitte");
- while(!zw.equals("ende"))
- {
- sum+=zahlwortzuzahl(zw);
- zw = InteractiveIO.promptAndRead("Zahlwort bitte");
- }
- InteractiveIO.write(sum+"");
- }
-
-
- public static int zahlwortzuzahl(String zahl)
- {
- int r = 0;
- switch(zahl)
- {
- case "eins":
- r = 1;
- break;
- case "zwei":
- r = 2;
- break;
- case "drei":
- r = 3;
- break;
- case "vier":
- r = 4;
- break;
- case "fünf":
- r = 5;
- break;
- case "sechs":
- r = 6;
- break;
- case "sieben":
- r = 7;
- break;
- case "acht":
- r = 8;
- break;
- case "eun":
- r = 9;
- break;
- case "zehn":
- r = 10;
- break;
- case "elf":
- r = 11;
- break;
- case "dutzend":
- r = 12;
- break;
- case "zwölf":
- r = 12;
- break;
- case "dreizehn":
- r = 13;
- break;
- default:
- r=0;
- }
- return r;
- }
-
-
-
-
- }
|