Professional Documents
Culture Documents
FUNDAMENTALS OF ALGORITHMS
&
COMPUTER PROBLEM SOLVING
ASSIGNMENT (15%)
Submission Date: Week 14 (18/07/2021)
*A late submission will be penalized. Any work which is found to be plagiarized will be awarded with no
mark.
Task 1:
Selection Control Structure
(20 Marks)
Sweet Cup Cakes Sdn. Bhd is a company which sells cupcakes and provides the delivery service
for their customer in Klang Valley, Negeri Sembilan and Melaka. There is a special promotion
for their customer based on number of cakes bought. This company requires a program which
can calculate the total price (before and after discount) and delivery charge based on the
destination. Tables below show the details about the price, delivery charge and promotion.
Table 3. Promotion
Number of cakes Promotion
Less than 20 pieces No discount
20-29 pieces 10% discount
30-49 pieces 20% discount
More than 50 pieces 30% discount
Write a complete C++ program that uses a while loop to perform the following:
Input scores for CSC126 exam for the students enrolled in CSC126 course. User has to
input number of students.
Find and display the total of the scores.
Find and display the highest and lowest scores.
Calculate and display the average of the scores.
Count and display how many students earned scores above and equal to 50 marks.
Count and display how many students earned scores below 50 marks.
Task 3:
Functions
(20 Marks)
Write a complete C++ program for WorldParking Sdn Bhd. to perform the following:
a. Write a return-value function named calcCharges() to calculate and return the parking
charges for the customers. The company charges a RM1.00 minimum fee to park for up to one
hour. An additional RM0.50 will be charged for each hour exceeding the first one hour. The
maximum charge for any given 24-hour period is RM10.00. Assume that no car parks for longer
than 24 hours at a time.
b. Write a void function named calcTotal() to calculate the total charges for all the
customers.
c. Write the main program that allows the user to input number of customers and the hours parked
for the customers. The program should use the function calcCharges()above to calculate
the parking charges for each customer and function calcTotal() above to calculate the total
charges for all the customers.
d. Finally, your program should output the parking charges for each customer and the total charges
for all the customers. Use the appropriate parameters to pass values in and out of
functions.
Rubrics Assignments
Runtime Does not execute due to syntax Executes without errors Executes without errors
errors
Poor design Good use of symbols,
No testing has been completed. spacing in output.
Produce incorrect results
Produce correct results
Delivery Not delivered on time and not Delivered on time and not in Delivered on time and in
in correct format correct format correct format