[Solved] Why is the wrong value being calculated


Two issues:

1) 060 is actually octal which in decimal is 48. So, remove all leading zeros.
2) Inside calculateCost change:

if (line[0] == "Mo" || line[0] == "Tu" || line[0] == "We" ||
    line[0] == "Th" || line[0] == "Fr")

to:

if (day == "Mo" || day == "Tu" || day == "We" ||
    day == "Th" || day == "Fr")

and

else if (line[0] == "Sa" || line[0] == "Su")

to

else if (day == "Sa" || day == "Su")

because when you call day = nextDay(day); obviously you change day and not line[0]. You ‘re getting 4.5 because line[0] remains "Su". Only day changes to "Mo".

0

solved Why is the wrong value being calculated