MezData-LogoCreative Commons License Lösung 2005-Wi-SE-A2

2. Java-Quelltext

public class Onlinekosten{
  /*  Onlinezeit in Minuten: ozeit
   *  Datenvolumen in MB: odaten
   *  Preisangabe in Euro
   */
   public static double berechneTarif(int tarif, int ozeit, int odaten){
     double preis =0.0;  
     switch (tarif){
       case 0: // call
         preis = 9.80;
         if (ozeit > 60 * 40)
           preis += (ozeit - 60 * 40)*0.006;
         break;
       case 1: // limit
         preis = 12.90;
         if (odaten > 6000)
           preis += (odaten-6000)*0.0079;
         break;
       case 2: // voluma
         preis = 9.90;
         if (odaten >2000)
           preis += (odaten-2000)*0.012;
         break;
       case 3: // Flat all room
         preis = 39.95;
         break;
       default:      
     }
     return preis;
   }
}

Struktogramm

© Oliver Mezger 20.11.2008 MezData.de Den Kontakt herstellen...