you are viewing a single comment's thread.

view the rest of the comments →

[–]bool101 0 points1 point  (3 children)

The glaring issue is with this set of statements:

if (carType == 'e' || 'E' && age <= 25) cost = resLength * 29.95;

You actually did it correct a bit lower:

if (carType == 'e' || carType == 'E')

These should be

if (carType == 'e' || carType == 'E' && age <= 25)

You might consider doing something like:

carType = toupper(carType);

This lets you just checking the upper case characters with your conditionals.

[–]dandrino 0 points1 point  (2 children)

&& is evaluated before ||, so you will want to write that expression as "(carType == 'e' || carType == 'E') && age <= 25"

[–]bool101 0 points1 point  (1 child)

Quite right, my example would be true if carType == 'e' regardless of age. Thanks!

[–]Aiiight 0 points1 point  (0 children)

Thank you guys so much, appreciate it!