Skip to content

Instantly share code, notes, and snippets.

@avermeulen
Created April 1, 2020 12:13
Show Gist options
  • Save avermeulen/5307f373d9466ddedd50cde471241a56 to your computer and use it in GitHub Desktop.
Save avermeulen/5307f373d9466ddedd50cde471241a56 to your computer and use it in GitHub Desktop.
package cost;
public class CalculateCost {
// calculate the sms cost
public static double smsCost(int qty) {
return 65 * qty;
}
// calculate the call cost
public static double callCost(int seconds) {
final int PER_SECOND_PRICE = 15;
return PER_SECOND_PRICE * seconds;
}
public double calc() {
return 0.0;
}
}
import cost.CalculateCost;
public class TotalCost {
public static void main(String[] args) {
// I sent 7 SMS's and made 3 calls of 37, 23 & 12 seconds.
// what is the total cost
double totalCost =
CalculateCost.smsCost(7) +
CalculateCost.callCost(37) +
CalculateCost.callCost(23) +
CalculateCost.callCost(12);
System.out.println("Total cost: R" + totalCost/100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment