posted 3 years ago

This next problem I have to solve involves Busses lol.

In a buss station, there are

The price for one ticket is

I have to calculate the

The number of adults and kids is given by input, I just have to calculate both cases...

I have NO idea how to solve this, or with what to solve this.... 2days left for the exam, and these type of exercies are very important, cause there will be one like this for sure!

In a buss station, there are

**N**adults, and**M**kids.The price for one ticket is

**100**(whatever that is dollars/euros). If an adult wants to travel with**K**kids, he will have to pay**ONE**ticket for himself, and**k-1**tickets for the kids (the ride for ONE kid is free). There is also a rule, that NO kid can ride without an adult.I have to calculate the

**Maximum**and the**Minimum**amount of money for which all the passengers would have to pay in order to ride.The number of adults and kids is given by input, I just have to calculate both cases...

I have NO idea how to solve this, or with what to solve this.... 2days left for the exam, and these type of exercies are very important, cause there will be one like this for sure!

posted 3 years ago

seems right to me. If you try it with different numbers, you'll see a pattern.

So there's two mathematical equations you can come up with:

minCost = (numOfAdults)(100) + ?

maxCost = (numOfAdults)(100) + ?

So there's two mathematical equations you can come up with:

minCost = (numOfAdults)(100) + ?

maxCost = (numOfAdults)(100) + ?

When you do things right, people won't be sure you've done anything at all.

posted 3 years ago

Maximum cost would probably be:

maxCost = (numOfAdults)(100) + (numOfKids-1)(100)

but the minimum, I guess we first check

1. if numOfAdults and numOfKids are equal, in that case it would just be (numOfAdults)(100),

2. if numOfAdults is bigger than numOfKids, in that case it would again be (numOfAdults)(100)

3. if numOfAdults is smaller than numOfKids, in this case I believe I should divide the num of kids/adults, and then I don't know lol... if it's a whole number, okay... (for example if 5 adults, 10 kids = 2kids per adult... but if we have 11/2 for example?

P.S; what do you suggest I solve it with?

maxCost = (numOfAdults)(100) + (numOfKids-1)(100)

but the minimum, I guess we first check

1. if numOfAdults and numOfKids are equal, in that case it would just be (numOfAdults)(100),

2. if numOfAdults is bigger than numOfKids, in that case it would again be (numOfAdults)(100)

3. if numOfAdults is smaller than numOfKids, in this case I believe I should divide the num of kids/adults, and then I don't know lol... if it's a whole number, okay... (for example if 5 adults, 10 kids = 2kids per adult... but if we have 11/2 for example?

P.S; what do you suggest I solve it with?

posted 3 years ago

1. if numOfAdults and numOfKids are equal, in that case it would just be (numOfAdults)(100),

2. if numOfAdults is bigger than numOfKids, in that case it would again be (numOfAdults)(100)

3. if numOfAdults is smaller than numOfKids, in this case I believe I should divide the num of kids/adults, and then I don't know lol... if it's a whole number, okay... (for example if 5 adults, 10 kids = 2kids per adult... but if we have 11/2 for example?

Each adult only gets one free kid division is unnecessary. It's the same cost at 5 adults and 11 kids if each adult gets two/three as if each one gets one and the last guy gets stuck with the rest. Right?

I think this might be closer:

maximumFreeChildren = ??? number of adults ???

numberOfPaidChildren = totalChildren - maximumFreeChildren

minCost = (numOfAdults)(100) + numberOfPaidChildren(100)

2. if numOfAdults is bigger than numOfKids, in that case it would again be (numOfAdults)(100)

3. if numOfAdults is smaller than numOfKids, in this case I believe I should divide the num of kids/adults, and then I don't know lol... if it's a whole number, okay... (for example if 5 adults, 10 kids = 2kids per adult... but if we have 11/2 for example?

Each adult only gets one free kid division is unnecessary. It's the same cost at 5 adults and 11 kids if each adult gets two/three as if each one gets one and the last guy gets stuck with the rest. Right?

I think this might be closer:

maximumFreeChildren = ??? number of adults ???

numberOfPaidChildren = totalChildren - maximumFreeChildren

minCost = (numOfAdults)(100) + numberOfPaidChildren(100)

When you do things right, people won't be sure you've done anything at all.

posted 3 years ago

- 1

Exactly!

I managed to make it work.... perfect!

I just checked if the num of kids is bigger than the num of adults, if yes, then I did kids-adults=gave me the number of kids which should pay *100...

THank youuuuuuu!! Make sure to check my next topic lol :p

Seriously, thank you for making it easier for me to prepare for the exam, I really appreciate it guys

I managed to make it work.... perfect!

I just checked if the num of kids is bigger than the num of adults, if yes, then I did kids-adults=gave me the number of kids which should pay *100...

THank youuuuuuu!! Make sure to check my next topic lol :p

Seriously, thank you for making it easier for me to prepare for the exam, I really appreciate it guys