Although I would use your CHILDREN_MALE and CHILDREN_FEMALE constants rather than using magic numbers.
It also doesn't use switch, but that's fine. You can do the same thing with a switch -- I just wasn't sure if switch was a requirement or not. =) But yeah that is functional.
EDIT:
Actually I just noticed you are checking if Age > 13 (greater), not < 13 (less)
EDIT 2:
With that, I'm going to have to call it a night. It's very late by me. I'll check this thread tomorrow.
Ok so I did do it with if else but switch is supposed to be required in my program. Don't know how to add it, can you help please? Don't have too much more time, have til about 12:30 pacific time. How would I be able to add switch into this?
so I did do it with if else but switch is supposed to be required in my program. Don't know how to add it, can you help please?
Take a look at my previous example of a switch statement:
1 2 3 4 5 6 7 8 9 10
switch( <expression> )
{
case <possible_value>:
// do something if <expression> == <possible_value>
break;
case <another_possible_value>:
// do something if <expression> == <another_possible_value>
break;
}
Compare that to a similarly structured if/else statement:
1 2 3 4 5 6 7 8
if( <expression> == <possible_value> )
{
// do something if <expression> == <possible_value>
}
elseif( <expression> == <another_possible_value> )
{
// do something if <expression> == <another_possible_value>
}
EDIT:
Also, you REALLY should be using your CHILDREN_MALE, CHILDREN_FEMALE, etc constants rather than using magic numbers in your code. Like... that's kind of important.
Hint: don't worry about the 10% tax when determining the base price. Tax can be added later.