/BillCalc.java Secret
Last active
August 16, 2016 03:58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.telco.billing; | |
public class BillCalc { | |
public final static String LITE_PACKAGE = "lite"; | |
public final static String MEGA_PACKAGE = "mega"; | |
public final static float LITE_PACKAGE_RENTAL = 500.0f; | |
public final static float MEGA_PACKAGE_RENTAL = 750.0f; | |
public final static float EXCESS_GB_CHARGE = 250.0f; | |
public float calc(String dataPackage, float excessAmount) { | |
float finalBill = 0; | |
float excess = excessAmount * EXCESS_GB_CHARGE; | |
switch (dataPackage) { | |
case LITE_PACKAGE: | |
float total = LITE_PACKAGE_RENTAL + excess; | |
finalBill = total + total * (10 / 100.0f); | |
break; | |
case MEGA_PACKAGE: | |
float totalMega = MEGA_PACKAGE_RENTAL + excess; | |
finalBill = totalMega + totalMega * (10 / 100.0f); | |
break; | |
} | |
return finalBill; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment