Skip to content

Instantly share code, notes, and snippets.

@kdkanishka
Last active August 16, 2016 03:58
Show Gist options
  • Save kdkanishka/b05f5950925fac7457464f7d2d242461 to your computer and use it in GitHub Desktop.
Save kdkanishka/b05f5950925fac7457464f7d2d242461 to your computer and use it in GitHub Desktop.
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