You are on page 1of 4

CSC126

FUNDAMENTALS OF ALGORITHMS
&
COMPUTER PROBLEM SOLVING

ASSIGNMENT (15%)
Submission Date: Week 14 (18/07/2021)

Lab Assignment Requirements:


a. Every assignment must have a comment header consists of the following:
/*
Name :MAISARAH SALWA BINTI SULAIMAN
Student ID :2020848748
Group :AS1162C1
Task : #Task1 #Task2 or #Task3
Program Description :
*/

b. Assignments are submitted in a form of softcopy:


 MS Words: (one word document file)
 C++ program
 Sample input and output
 Source code (.cpp) of Task 1, Task 2 and Task 3

c. The softcopy of the assignment should be submitted in the Google Classroom

*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 1. Price of Cake


Cake code Cup cake Price/ piece
1 Chocolate moist RM 2.30
2 Red velvet RM 3.00
3 Banana RM 1.50

Table 2. Delivery Charge


Destination code Destination Delivery charge
1 Klang Valley RM 10.00
2 Negeri Sembilan RM 20.00
3 Melaka RM 35.00

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

The program must perform the following task:


 In order to identify discount and delivery charge, customer require to input:
o Cake code
o Quantity
o Destination code
 The program should able to display the total quantity of cupcakes, the total price (before
and after discount) and delivery charge based on the destination.
Task 2:
Looping/Repetition Control Structure
(20 Marks)

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

Requirements Poor Fair Good


(0-1) (2-3) (4-5)
Documentation Completed less than 50% of Completed at least 50% of Completed 100% of
the requirements (source code the requirements requirements
and sample input/output)

Does not comply with


requirements (does something
other than requirements).
Coding No programmer name included No programmer name Includes name, and
standard in block comment header included in block comment assignment title in block
header comment header
Not using appropriate/suitable
variables Using appropriate/suitable Good use of variables and
variables constants
Poor use of white space
(indentation, blank lines) White space makes program Good use of white space
making code hard to read. fairly easy to read. and organized work.

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

You might also like