Created
April 1, 2020 12:13
-
-
Save avermeulen/5307f373d9466ddedd50cde471241a56 to your computer and use it in GitHub Desktop.
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 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; | |
} | |
} |
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
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