# Best Fare Calculator

Hi All,

I’m currently working on building the “Best Fare Calculator” project and I’m positivie the code I’ve written is incorrect. Also, the compiler tells me so. I want to know exactly what my mistakes are, but of course, there is nothing to help me view it. Does anyone have an idea where I can at least get a little help correcting my mistakes?

Thanks

Hey @dscntr17!

``````import java.util.Arrays;

public class TransitCalculator() {

public TransitCalculator() {
String [] rides = {"Pay-per-ride", "7-day unlm", "30-day unlm"};
double [] prices = {2.75, 33.00, 127.00};
}

public double unlimited7Price() {
if(prices[1] * 3 / 20 ) {
return 4.95;
}
else if(prices[1] * 4 / 50) {
return 2.64;
}
else(prices[1] * 1 / 14) {
return 2.36;
}

}

public double getRidePrices() {
if(prices[0] % 1) {
return 2.75;
}
else if(prices[1] % 7) {
return 4.71;
}
else(prices[2] % 30) {
return 4.23;
}
}

public String getBestFare(){
for(double prices : String getRidePrices) {
return "You should get the 30-day Unlimited option at 4.23 per ride.";
}
}

public static void main(String[] args) {

}
}
``````

So, basically I need to determine the correct fare option for transit riders. I know there’s no code in my main, which is probably one of the reasons why I’m not getting a correct output. But other than that, I’m stuck.

And I don’t know why the code didnt indent when I copied this over.

Hey,

Your code didn’t indent because you didn’t surround it with backticks… checkout this topic to see how to properly format your code:

1 Like
1 Like

Hello, @dscntr17.

Question for you. What condition(s) are you testing in your `if` statements? They are all similar to this:

``````if(prices[1] * 3 / 20 )
``````

When we evaluate the expression that is being tested for `truthiness` we have:

``````if(33.00 * 3 / 20)

``````

So, the entire `if` is:

``````if(4.95) {
return 4.95;
}
``````

I’m unsure where you are going with these. It seems you may have misinterpreted the instructions, and may need to go back and review the suggested prerequisites:

1 Like

Ok, I see where I went wrong on that method. I will go back and re-read my notes. And yes, I may not have understood the directions entirely. I’m very new to this course, so I’m not confindent in the coding I do.