Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Alternative method solutions

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;
}
}```

2. ## Re: Alternative method solutions

These methods don't do the same thing. How about you tell us which one accomplishes the goals you listed?

3. ## Re: Alternative method solutions

Am not sure that's why I posted

4. ## Re: Alternative method solutions

Well, what does each method do? What happened when you stepped through it with a piece of paper and a pencil, or a debugger? Or just added some print statements?