Melaka state government plans to develop a system to guide the tourists to go to the nearest tourism destination spot. The system asks for password before the user is able to use the system. The system allows for 3 times of password entry attempts. If all 3 attempts are failed, the system will be terminated. However, after successful login, the system will ask user’s current location and their preferred destination spot. The user may select one or more destination, but only the nearest one will be suggested to the user, and the cost of transportation to go to the suggested destination is given. You are, as the developers of the system, must follow the requirements described below. However, you are free to add your own functions, variables, or et cetera.
Table 1: Defined Constants Name Value Description COST 0.5 To store the cost of transportation for every kilometers.
SIZE
5
To store the number of tourism destination spot currently available.
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
2
DITG 1113 – Computer Programming
Table 2: Global Variables Name Value Description coordinates [SIZE][2] Double To store the coordinates of all tourism destination spot in Melaka, in Cartesian coordinate system (x and y).
choice [SIZE]
Integer
To store the user destination preferences. password[N] Integer To store the password of all users allowed using the system, where N is the number of group members. The password is initialized with the last 8 numbers of group members matric number, for example {30920020, 30610060}
Table 3: Function Declarations Name Return Type Parameters header() None -
login()
Integer
- legend() None -
input_location()
None
current[] with data type double input_choice() None index with data type integer answer with data type integer, passed by reference.
search()
None
current[] with data type double calculate() Double distance with data type double
Table 4: Function Definitions Name Local Variables Description main() current[2] with data type double Acts as the main entry to the system. This function does these processes:
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
3
DITG 1113 – Computer Programming Name Local Variables Description Initialize the value of global variable coordinates with random values from 1-100. Call header(). Call login(). These following processes only executed if the login is successful: Call header(). Call legend(). Call input_location(). Call input_choice(). Call search().
header()
None
Displays the system header. login() password with data type integer. status with data type integer. counter with data type integer, set as static This function does these processes: Read password from user. Verify password. Recursive call upon wrong input. Return status
legend()
None
Displays the coordinates of all tourism destination spot in tabular format. input_location() None This function does these processes: Read user location. Recursive call upon wrong input.
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
4
DITG 1113 – Computer Programming Name Local Variables Description
input_choice()
None
This function does these processes:
Read user choice on specified destination index.
Recursive call upon wrong input. search() distance with data type double, initialized with 150. index with data type integer. This function does these processes: Search for nearest tourism destination spot (hint: use Pythagoras theorem to find the distance between two points). Display the nearest tourism destination spot and its distance from current location, along with the cost to go to this destination, using calculate() function.
calculate()
-
Calculates the cost of transportation given the rounded up distance.
Table 1: Defined Constants Name Value Description COST 0.5 To store the cost of transportation for every kilometers.
SIZE
5
To store the number of tourism destination spot currently available.
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
2
DITG 1113 – Computer Programming
Table 2: Global Variables Name Value Description coordinates [SIZE][2] Double To store the coordinates of all tourism destination spot in Melaka, in Cartesian coordinate system (x and y).
choice [SIZE]
Integer
To store the user destination preferences. password[N] Integer To store the password of all users allowed using the system, where N is the number of group members. The password is initialized with the last 8 numbers of group members matric number, for example {30920020, 30610060}
Table 3: Function Declarations Name Return Type Parameters header() None -
login()
Integer
- legend() None -
input_location()
None
current[] with data type double input_choice() None index with data type integer answer with data type integer, passed by reference.
search()
None
current[] with data type double calculate() Double distance with data type double
Table 4: Function Definitions Name Local Variables Description main() current[2] with data type double Acts as the main entry to the system. This function does these processes:
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
3
DITG 1113 – Computer Programming Name Local Variables Description Initialize the value of global variable coordinates with random values from 1-100. Call header(). Call login(). These following processes only executed if the login is successful: Call header(). Call legend(). Call input_location(). Call input_choice(). Call search().
header()
None
Displays the system header. login() password with data type integer. status with data type integer. counter with data type integer, set as static This function does these processes: Read password from user. Verify password. Recursive call upon wrong input. Return status
legend()
None
Displays the coordinates of all tourism destination spot in tabular format. input_location() None This function does these processes: Read user location. Recursive call upon wrong input.
Faculty of Information and Communication Technology | Universiti Teknikal Malaysia
Melaka
4
DITG 1113 – Computer Programming Name Local Variables Description
input_choice()
None
This function does these processes:
Read user choice on specified destination index.
Recursive call upon wrong input. search() distance with data type double, initialized with 150. index with data type integer. This function does these processes: Search for nearest tourism destination spot (hint: use Pythagoras theorem to find the distance between two points). Display the nearest tourism destination spot and its distance from current location, along with the cost to go to this destination, using calculate() function.
calculate()
-
Calculates the cost of transportation given the rounded up distance.