Still practicing java questions for improvement
I completed 2 solutions to a question, please tell me which one is more accurate:
This is what the question is based on:
land line to land line :20 cents
land line to LOWCALL mobile: 50 cents
land line to other mobile network: 1.20
Packages:
0 -NONE
1: GOLD >>>100.00 1 MONTH, 500 free land line mins and 50 free LOWCALL mobile mins
2: PLATINUM>>>150.00 1 MONTH, UNLIMITED free land line mins and 100 free LOWCALL mobile mins
So with the given parameters I had to calculate the number of landLine mins using a mthod:
Here is my 1st solution:
public static double calcLandMinutes (int numLandLineMins, int packageNum){ double landLineCost=0; if(packageNum==0) { landLineCost = numlandLineMins * 0.20; } else if(packageNum==1) { landLineCost = 100; } else if(packageNum==2) { landLineCost= 150; } }
Here is my 2nd solution:
public static double calcLandMinutes (int numLandLineMins, int packageNum){ double landLineCost=0; if(packageNum==0) { landLineCost = numlandLineMins * 0.20; } else if(packageNum==1) { if (numLandLineMins > 500) { landLineCost = (numlandLineMins - 500 )* 0.20; } else { landLineCost = 100; } } else if(packageNum==2) { landLineCost= 150; } }