Applications Programming --- Lab 5

Objective:

References:

Problem Description

A new-age Taxi company let its riders have two choices of calculting ride fare:

  1. the user can negotiate a fare with the driver before the ride (Uber style). Or
  2. the fare is calculated based on the distance travelled and the idle minutes during the ride (traditional Taxi style). If a rider choose this style, the company charges $1.5 per kilometer and $0.55 for each minute the taxi is not moving during the ride.

Your Tasks:

  1. Download the Lab 5's template workbook file: lab5-input.xlsx.
  2. Open the template file you just downloaded and design and implement a VBA program that calculate the taxi fare for a user based on the user choice and trip information. for the farmer.
    1. Your program first ask the user which style of fare calculation he/she wants to use;
      (Hint: your program can prompt the user to enter U for Uber style and T for traditional style, and then read the user input.)
    2. If the user chooses Uber style, ask the user to enter the negotiated fare amount.
    3. If the user chooses the traditional style, ask the user to enter the following information:
      • the distance travelled in kilo-meters of the ride, and
      • the number of minutes the taxi was not moving (idling) during the travel.
    4. Calculate the fare according to the information collected;
    5. Use a message box to show the fare;
    6. Save the trip information, user choice and fare information to the appropriate cells in row 9 of the Excel file.
  3. Save your work to a Macro-enabled Excel file (with the extension name .xlsm).

In order to make your program sufficiently robust, when your program collect the data of pre-negotiated fare, distance travelled and idling minutes, always perform user input validation by first read in these numbers as strings, then check whether these strings are numerical numbers (using IsNumeric function). If they are numbers, then convert them to floating point numbers (using CDbl function) and test whether these numbers are positive ones.

If the user enters a non-numerical data or negative numbers as pre-negotiated fare, distance and/or idling minutes, using message box to display an appropriate error message and then terminate your program right away.

When you develop your VBA program, you need to pay attention to the following things:

There is a weekly Assignment 5 following this lab.