Lab 4
Lab 4
Lab 4
Selection
Learning outcome:
At the end of this lab, student should be able:
solve the problem and develop a simple program using control statements.
** Copy or other forms of cheating is forbidden. The standard penalty for the first
offence is to award 0 to all parties concerned.
1. Modify the Java Program that you have developed in Lab 2 (question 5). Based on
the figure below, identify the status of the BMI.
Aisyah, your height is 1.73 meters and your weight is 66.00 kg.
Your BMI is 22.05, you are Normal.
2. Modify the Java Program that you have developed in Lab 3 (question 2) in
calculating the total mark of CSC3100. Add another column called Grade based
on the following table:
Lab4-G3
CSC3100 – PROBLEM SOLVING AND PROGRAMMING CONCEPTS SEM 2 2023/2024
3. An Internet service provider has three different subscription packages for its
customers as shown below:
Based on the monthly package that has been identified, calculate, and display a
customer’s total monthly bill. Before coding, complete the pre-programming phase
(develop the PAC, IPO, flowcharts, and write the pseudocode).
Sample output:
Enter package code: 2
Enter minutes voice call: 300
4. The table below shows the electricity charges for domestic consumers
(households) in Malaysia.
For example, if the usage is 400kWh a month, these are the calculations:
First 200kWh [(200xRM21.80)/100] = RM43.60
Next 100kWh [(100xRM33.4)/100] = RM33.40
Next 100kWh [(100xRM51.60)/100] = RM51.60
TOTAL = RM128.60
5. A mail-order house sells five products whose retail prices are as follows:
Product 1 = RM2.98; product 2 = RM4.50; product 3 = RM9.98; product 4 = 4.49
and product 5 = RM6.87.
Write a program that reads a pair of numbers, i.e. the product number and the
quantity sold, then calculates and displays the total retail value of the product sold.
Customers should know the product number and price before choosing the
product. Use the switch statement for the selection process.
Lab4-G3
CSC3100 – PROBLEM SOLVING AND PROGRAMMING CONCEPTS SEM 2 2023/2024
Extra Exercise
6. KMHZ bookstore is looking for employees. Applicants must be male and aged
between 18 to 30 years. If both conditions are not met, the application will be
rejected.
7. You are required to determine admission to the Form 4 science stream class
based on the PT3 examination results. The condition is that students must get 5A
and above and get an A in science and mathematics subjects or get an A in
English and mathematics subjects
8. Price of a movie ticket is based on the age of the customer. The normal price for
adults is RM7.00. If the age is below than 13 years old but greater than 3 years
old, the price is about 30% of the normal price and if below than 3 years old is
free. If the age is greater than 60 years old, the price is about 50% of the normal
price. Develop a program and display the price need to be paid by the customer.
9. A vendor company will give some discounts on its products based on the total
units bought by the customer and the price of each unit. The table shows the
discount given with the price and the total units. Write if…else statements based
on the table.
Lab4-G3