Okay, well you have a few problems here.
A
switch
statement works like so:
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;
}
|
You seem to be confusing a switch with an
if
statement. Look at what you have here:
1 2 3
|
switch(Age<12)
{
case 'm': case 'M': (CHILDREN_MALE*.10);
|
Your expression is
Age < 12
, which will be either
true
if they're younger than 12, or
false
if they're not. This means you can realistically only have 2 cases because there are only 2 possible values: true and false.
However you have 4 values: 'm', 'M', 'f', and 'F' -- which of course is nonsensical because
Age<12
cannot be
'm'
. So you seem to be mixing up gender with age.
This would make much more sense:
1 2 3
|
switch(gender)
{
case 'm': case 'M': //...
|
The expression here is 'gender'... which could be 'm', 'M', 'f', or 'F'. So now your cases make sense.
You probably want to put the age check in an if statement that is separate from your switch.
Also.... this bit doesn't make sense either:
(CHILDREN_MALE*.10);
This effectively does nothing. You are multiplying two numbers, but you don't capture the result so it just gets thrown away. If you are trying to calculate the cost, you will need to assign this to some kind of variable.
Looking at your code, you seem to have an 'Mcost' variable that you don't really use. Perhaps you meant to assign the result to that. This would make much more sense:
Mcost = (CHILDREN_MALE*.10);