Tuesday, March 4, 2008

Assignment 3

Assignment A3: Functions (Duration: 2 practical periods)

Travel Distance Calculator computes travelling time, petrol consumption and total petrol cost from a departure city to a destination city.

Write a function travelDistanceCalculator that accepts travel distance, average speed in kilometre per hour, petrol consumption in kilometre per litre, petrol cost in Ringgit Malaysia per litre and displays travel distance, travelling time, total petrol consumption and total petrol cost.

Write a program in C that reads travel distance between two cities, petrol consumption in kilometre per litre, petrol cost in Ringgit Malaysia per litre and average speed in kilometre per hour, and calls function travelDistanceCalculator. The user interface screen may appear as in the figure below.





You must construct a pseudocode or flowchart before writing the program.