0% found this document useful (0 votes)
38 views3 pages

Lab Task 3 PF 2022

The document outlines a laboratory exercise on programming control structures for a Programming Fundamentals course, providing 3 questions that require students to rewrite nested if statements as switch case statements, write a program to calculate book discounts based on quantity, and write a program to perform basic math operations based on user input.

Uploaded by

annasuhah03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Lab Task 3 PF 2022

The document outlines a laboratory exercise on programming control structures for a Programming Fundamentals course, providing 3 questions that require students to rewrite nested if statements as switch case statements, write a program to calculate book discounts based on quantity, and write a program to perform basic math operations based on user input.

Uploaded by

annasuhah03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

POLYTECHNIC SULTAN MIZAN ZAINAL ABIDIN

DEPARTMENT OF INFORMATION AND COMMUNICATION TECHNOLOGY

DFC 20113
PROGRAMMING FUNDAMENTALS

TOPIC CHAPTER 1 2 3 4 5
ASSESMENT LAB TASK 1 2 3 4 5

NAME
REG NO
PROGRAMME

INSTRUCTIONS :

1. Answer ALL the questions


2. Submit on ………………….

MARKING SCHEME

CLO2P PLO3

TOTAL / 20

Prepared by : Checked by : Verified by :

…………………………… …………………………………. …………………………………


(PENSYARAH . …
KURSUS) (PENYELARAS KURSUS) (KETUA PROGRAM / KETUA
JABATAN)
LABORATORY EXERCISE 3 : CHAPTER PROGRAM CONTROL STRUCTURES [CLO 2][PLO 2]

This Laboratory Task encompasses activities 3A , 3B and 3C.

At the end of this lab, you should be able to:

1. Convert nested if statement into switch case statement.


2. Solve problem that apply selection control structures.

Question 3A

Rewrite the code below into switch case statement.

#include <iostream>

using namespace std;


int main()
{
int discount;
cout << "Enter Your Code - 1.Food, 2. Health, 3. Electric, 4. Cloth : ";
cin >> discount;
if (discount==1)
cout << "Discount 5%" << endl;
else if (discount==2)
cout << "Discount 6%" << endl;
else if (discount==3)
cout << "Discount 9%" << endl;
else if (discount==4)
cout << "Discount 4%" << endl;
else
cout << "Code Not Recognized" << endl;
}

(5 marks)
Question 3B

Write a program that present the user to enter quantity of book and price of book.

quantity Nett price

More than equal 10 books Discount 20%

Between 5 – 9 books Discount 10%

Less than 5 book Discount 5 %

One book only No discount

(5 marks)

Question 3C

Write a program that prompts the user to input two number and symbol ( + , - , * , /,%). The program
should then output the number and message saying result of the operation. The program also have
display menu.

Example of output : (10 marks)

You might also like