We just started to learn decisions, and I'm confused.
Wonder if someone could help me figure this out.

In this assignment, you are going to calculate how much a BahnCard costs to buy, using the following rules.

* BahnCard25. The card costs 110 euros for a first class card and 55 euros for a second class card. However, if the rider is younger than 19, a second class card can be purchased for 10 euros.
* BahnCard50. The card costs 440 euros for a first class card and 220 euros for a second class card. However, both of these cards can be purchased at half price (220 for first class, 110 for second class) if any one of the following three conditions applies:
o The person is seventeen years old or younger.
o The person is sixty years old or older.
o The person is a student who is younger than 27.
* BahnCard100. The card costs 5900 euros for a first class card and 3500 euros for a second class card.

Now I just would like a push in one direction, so I'll just ask for help on the BahnCard100

``````public int bahnCard100Price (int desiredClass)
{
double cost;

if (desiredClass = 1)
cost = 5900;
else

if (desiredClass = 2)
cost  = 3500;
return cost;
}``````
3
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by scorio

You didn't post a question...

``````public int bahnCard100Price (int desiredClass)
{
double cost;

if (desiredClass = 1)
cost = 5900;
else

if (desiredClass = 2)
cost  = 3500;
return cost;
}``````

Do you mean:

``````public int bahnCard100Price (int desiredClass)
{
if(desiredClass==1)
cost = 5900;
else // we can presume at this point it is second class card but you could also use "else if(desiredClass==2)"
cost = 3500;

return cost;
}``````