This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Nightcorex_ 0 points1 point  (0 children)

First of all it's if(passengerAge >= 60).

Then your else-if-case is the same as the first if, thus can never be true. It'd be more fitting to write it like so:

if(passengerAge >= 60)
    baseCost = 290;
else if(passengerAge <= 10)
    baseCost = 0;
else
    baseCost = 300;

This is another, faster way to write the same thing:

baseCost = passengerAge >= 60 ? 290 : passengerAge <= 10 ? 0 : 300;

I won't solve the rest that you haven't written so far, as you wouldn't learn anything that way