twoodcc said:

thank you for your reply.

so do i have to tell matlab that it's in km and in km/hour?

and were the commands correct so far?

I didn't actually check your commands closely but at first glance they look like they should work. There might be some minor tweaking but I think you'll get the idea.

As for telling matlab that it's in km and km/hour -- not exactly. You -- the programmer -- need to keep track of your units.

(I don't mean to sound condescending or anything, so I apologize if I do, I really have no idea what level of math this is (high school? college?), so I have to appeal to the lowest common denominator

I also don't want to give away the answer directly, so excuse me for being a bit obtuse at times too.)

Forget all about Matlab for the moment, and suppose you are trying to solve this problem with a paper and pencil. You need to work through the exact steps first. THEN you can worry about whether or not the code is correctly performing these steps. In fact, this is how you would "unit test" your code once you get it done - you calculate your answer by doing it by hand, and then run your code. If your code produces the same answer, then you know you coded it correctly.

So, given:

fuel_consumption = 0.078 liters/hour

distance = 4.34 billion km

speed = 5.2 km/sec

fuel_provided = (user provided) liters

In order to answer "will it have enough fuel", you first need to ask "how much fuel will it need?" Ultimately you want to compare: is fuel_provided >= fuel_needed?

So how do you calculate fuel_needed? You need to know the fuel consumption rate (which is given) and how long the spacecraft will be burning fuel (time).

OK, so now you need to calculate how much time the spacecraft will be travelling for. How do you do that? You'll need to know the distance (given) and speed (given).

But your distance is in km's per hour and your speed is in km's per second. How do you convert km's per second into km's per hour?

... and so it goes. Break it down into little steps. Your steps on paper should look like this:

1. Convert speed from km/sec to km/hour

2. Time = ???

3. Fuel_needed = ???

4. Is fuel_provided > fuel_needed?

Then you can write Matlab code to get the data from the user, do the calculation, and print the answer.