CSc 3610 In Class Assignment 1

Documentation The first thing in your program should be documentation, such as:
  % in_class1.m
  %
  % Author: (Your Name)
  % Account: (your account name)
  % CSc 3610 Program #1
  %
  % Due date: (put the due date here)
  %
  % Description:
  % (Give a brief description of what your program does.)
  %
  % Input:
  % (State what the program inputs are.)
  %
  % Output:
  % (State what the program outputs are.)
  %
  % Usage:
  % (Give an example of how to use your program.)
  % (For example: out = myabs(in); )
  %


Objectives

  1. Practice designing a program.
  2. Practice implementing a program design in MATLAB.
  3. Practice testing a program.
  4. To get familiar with the programming environment.

Introduction
A spacecraft leaves the Earth headed for the Planet-Formerly-Known-As-Pluto, traveling at 5.2 km/sec. How long will it take to reach its destination? Assume that is 4.34 billion km away from the earth. Suppose that it consumes fuel for stability systems and life support. If it starts out with 50 liters of fuel, and consumes it at a rate of 0.078 liters every hour, will it have enough fuel to reach ? What if the spacecraft can travel at half the speed by consuming only one-quarter of the fuel?

Assignment
Your program should input the distance (in kilometers), the amount of fuel (in liters), and the speed. Output this information, describing it briefly. Use the input command, as the following example shows.

>> distance = input('How far away is Decatur? ');
How far away is Decatur? 8
>> disp(sprintf('Decatur is %d kilometers away.', distance));
Decatur is 8 kilometers away.
>>

Your program should report how long it would take to reach the destination, and if the fuel will run out.

Your program should work for all possible inputs. Make sure that you test it with several different cases. Suppose the distance is so far that it would take millions of years. In this situation, your program should end (after, say, 80 simulated years) with a message informing the user that we have reached the destination, and there are still X kilometers left to go.


Write Down:
  1. your design (behavior, variables, operations, algorithm)
  2. your source code
  3. the output from at least three different executions in which you test the correctness of your program (using a script*). One test should be with the values given above.
Make sure that your printouts use a monospaced font.


* A script is short for typescript, where everything typed is saved. This keeps a log of all the input and output. MATLAB provides this capability with the diary command. Type help diary at the MATLAB prompt for more information.