I have just enrolled to a computer sciencee class, and my teacher gave us an assignement about writing a pseudo code, but it's my first time being in computer science class and i don;t have any experience in computer science. Can someone help me?

here is the problem:
You and your friend decided to go to the beach. You have left home one hour earlier than your friend did. Assuming the traffic is normal and you drive 60m/hrs and your friends drives 70m/h. how long will it take your friend to catch up before getting to the beach.
here is the equation
S2*t=s1*(t+h)
s1= your speed
s2= friend speed
h is the hour
if you had to stop for 1/2 hour for food and to put gas in your car. then how long will it take to meet ?

I need to write this in pseudo code

Recommended Answers

All 2 Replies

This can be solved analytically, why pseudocode? The pseudocode in this case is almost like the mathematical expressions needed to solve it.

s2*t = s1*t + s1*h <=> t(s2-s1) = s1*h <=>

t = s1*h/(s2-s1)

which is the pseudocode and the real code for that matter.

I agree with SasseMan, the problem is pure analytic. In addition, if you have to stop for 30min for gas and food, that depends where on the road you have to do it. If the gas station is reached before the t calculated in the previous section, then you have to recalculate the equation with h/2 instead of h. If the gas station is reached after that t, then it doesn't matter, because you have already caught up with your friend.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.