CSC186 Test Revision
CSC186 Test Revision
PART A
An insurance company wants you to develop an automated process for calculating vehicle
insurance. The company requires information about vehicle such as market value (RM), total
passenger and cubic capacity (CC) of the vehicle. The range of cubic capacity is shown in the
table below:
Based on the above information and using object-oriented approach, answer the following
questions.
b) Identify ONE (1) class name and THREE (3) attributes in the class.
(2.5 marks)
d) The system can calculate the vehicle insurance for three different types of vehicles such
as motorcycle, car and lorry.
Happy Food is selling baby foods such as puree, food powder and fruit cereal. The company
is planning to develop the inventory system to assist them in keeping the inventory using the
following information.
.
.
.
a) Write a complete class definition for class Product that contains all attributes as
mentioned above and the following methods.
x Normal constructor.
x Accessor methods for each data member.
x toString() method that returns all data members of the class.
x calculateSellingPrice() method that finds and returns the selling price for
customer. Product type contains in product name. For example, product type of
Spinach Puree is puree, Banana Cereal is cereal and Chicken Powder is powder.
The calculation of selling price is based on the following table:
i) Declare an object of type Product named prod, read and store all data into the
object.
(3 marks)
ii) Display all information of the product with the quantity left is less than 50.
(2 marks)
iii) Find and display the gross profit for the product based on the formula below.
Gross Profit = (Selling Price x Quantity) - (Stock Price x Quantity)
(3 marks)
iv) Display the product name for baby above than 7 months old.
(2 marks)
QUESTION 3 (5 marks)
b) Siti Norliza is an artist singing a balada song together with two dancers. Balada is a type
of genre. The details of dancers are as follows.
Referring to the information in b), write Java program statements for the tasks below.
i) Declare and create an array named arrayD to store all dancers as mentioned above.
(1 mark)
ii) Create two dancers and store the objects into the array in b i).
(2 marks)
Smile Always Gift Shop is a gift shop that offers a variety of gifts such as fresh flowers,
chocolates, candies and many more for their customers. In order to make their business more
organized, especially in keeping track of customer records including the distance to deliver
the gift, the owner is planning to move from a manual to a computerized system. Thus, you
are assigned to develop an application using object-oriented approach.
The following table depicts the hot selling products for this shop.
Customer who become a member receives a 10% discount on purchases of at least RM200.
The following is a class definition for GiftProduct.
//default constructor
//getter methods
//processor methods
(1 mark)
b) Define the following methods for class GiftProduct.
i) Write a method named calcTotalAmount() to find the total amount that the
customer need to pay. The total amount must include the product price, discount (if
any) and delivery costs as listed below:
(6.5 marks)
ii) Write a method named cMemberYear()to return year of membership. The year of
membership can be accessed by id member. The illustration shows how the year
can be accessed. For example, id member is 2022-00001.
2022-00001
year unique
number (2 marks)
ii) Assume all data has been stored into the array. Change data on third object of
GiftProduct Details
Category Code : BS123
Product Code :B
Quantity :2
Distance : 60
Customer Details
Name : Sophia Al-Karim
ID Member : 2022-00034
Address : PT01, Bukit Ilmu, Machang, Kelantan
Membership : true (2 marks)
iii) Display number of customers who become member in 2022. (2.5 marks)