0% found this document useful (0 votes)
8 views43 pages

Electronicdevice Pseudocode On Docs

Uploaded by

ikmal hakim
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)
8 views43 pages

Electronicdevice Pseudocode On Docs

Uploaded by

ikmal hakim
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/ 43

BEGIN

//Declare the variables


CHAR deviceType
STRING brand, model, addOn
INT modelAmount

//Declare and initialise the variables


FLOAT subtotal = 0, totalPrice = 0
CHAR
//Initialise device types
A = Smartphone
B = Tablet
C = Smartwatch

//Initialise brands
B1 = Apple
B2 = Samsung
B3 = HuaWei

STRING
//Initialise smartphone models
PM11 = iPhone 15 Pro Max
PM12 = iPhone 15
PM13 = iPhone 14
PM21 = Samsung Galaxy S23 Ultra
PM22 = Samsung Galaxy Z Flip5
PM23 = Samsung Galaxy Z Fold5
PM31 = HuaWei P60 Pro
PM32 = HuaWei Mate X3
PM33 = HuaWei Nova 11 Pro

//Initialise tablet models


TM11 = iPad Pro
TM12 = iPad Air
TM13 = iPad 10th Gen
TM21 = Samsung Galaxy Tab S9 Ultra
TM22 = Samsung Galaxy Tab S9 FE+
TM23 = Samsung Galaxy Tab A9+
TM31 = HuaWei MatePad Pro
TM32 = HuaWei MatePad Air
TM33 = HuaWei MatePad

//Initialise smartwatch models


WM11 = Apple Watch Series 9
WM12 = Apple Watch Ultra 2
WM13 = Apple Watch SE
WM21 = Samsung Galaxy Watch6
WM22 = Samsung Galaxy Classic
WM23 = Samsung Galaxy Watch4
WM31 = HuaWei Watch 4 Series
WM32 = HuaWei Watch GT 4
WM33 = HuaWei Band 8

FLOAT
//Initialise smartphone prices
PP11 = 6499
PP12 = 4899
PP13 = 4299
PP21 = 5699
PP22 = 4499
PP23 = 6799
PP31 = 4699
PP32 = 8888
PP33 = 2599

//Initialise tablet prices


TP11 = 5899
TP12 = 3649
TP13 = 2749
TP21 = 5999
TP22 = 3399
TP23 = 1099
TP31 = 4299
TP32 = 2799
TP33 = 1499

//Initialise smartwatch prices


WP11 = 3299
WP12 = 3799
WP13 = 1199
WP21 = 1499
WP22 = 1499
WP23 = 799
WP31 = 2499
WP32 = 1699
WP33 = 199

STRING
//Initialise add-ons
A1 = Brand new power adpater with type-C cable
A2 = New high quality wireless on-ear headphones
A3 = New high quality wireless earbuds
A4 = Silicone phone case
A5 = Magnetic wireless charger
A6 = Portable bluetooth speaker
N = No add-on purchased

FLOAT
//Initialise add-on prices
AP1 = 154
AP2 = 1200
AP3 = 132
AP4 = 144
AP5 = 132
AP6 = 900

//Introduce the store and the promotion


PRINT
"Welcome to Machine Device Store!
It's grand opening, and a promotion is held in a period of time.
An add-on with 40% off price per customer is available for customers who have purchased the products of the store."

//Display the products of the store and ask user to choose


PRINT
"We have 3 types of electronic devices: Smartphones, Tablets, and Smartwatch with different brands.
They are Apple, Samsung, and HuaWei.
Which device are you considering, my good Sir/Madam? (A: Smartphone, B: Tablet, C: Smartwatch)"

INPUT deviceType

//Device types
//Do while to try again
DO
IF deviceType is A or a
THEN PRINT
"You have chosen smartphone!
Which brand would you like? (B1: Apple, B2: Samsung, B3: HuaWei)"
INPUT brand

//Brands
DO
IF brand is B1 or b1
THEN PRINT
"Very nice! These are the models of " << B1 << "."
| Enter | Model |
-----------------------------------------
| PM11 | iPhone 15 Pro Max |
| PM12 | iPhone 15 |
| PM13 | iPhone 14 |
What is your choice?"
INPUT model

//Convert user enter to uppercase


model = TOUPPER(model);

//Models
DO
IF model is PM11
THEN PRINT
"You chose " << PM11 << "! "
"Please enter the amount of " << PM11 << " would you like to buy."
INPUT modelAmount

//Model amount
DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM11 << ". "
//Calculate the subtotal
//Set 2 decimal digits
subtotal = modelAmount * PP11
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

//Display the options of add-on and prices


PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
//Repeat if invalid input
DO
//Ask for add-on
INPUT addOn

//Convert input user to uppercase


addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM11 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM11 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM12


THEN PRINT
"You chose " << PM12 << "! "
"Please enter the amount of " << PM12 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM12 << ". "
subtotal = modelAmount * PP12
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM12 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM12 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM13


THEN PRINT
"You chose " << PM13 << "! "
"Please enter the amount of " << PM13 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM13 << ". "
subtotal = modelAmount * PP13
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn
addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM13 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM13 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N
ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (PM11, PM12, PM13)
WHILE repeat again when model is not PM11, PM12, PM13

ELSE IF brand is B2 or b2
THEN PRINT
"Very nice! These are the models of " << B2 << "."
| Enter | Model |
-----------------------------------------
| PM21 | Samsung Galaxy S23 Ultra |
| PM22 | Samsung Galaxy Z Flip5 |
| PM23 | Samsung Galaxy Z Fold5 |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is PM21
THEN PRINT
"You chose " << PM21 << "! "
"Please enter the amount of " << PM21 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM21 << ". "
subtotal = modelAmount * PP21
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM21 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM21 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM22


THEN PRINT
"You chose " << PM22 << "! "
"Please enter the amount of " << PM22 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM22 << ". "
subtotal = modelAmount * PP22
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM22 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM22 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM23


THEN PRINT
"You chose " << PM23 << "! "
"Please enter the amount of " << PM23 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM23 << ". "
subtotal = modelAmount * PP23
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END
CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM23 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM23 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (PM21, PM22, PM23)
WHILE repeat again when model is not PM21, PM22, PM23

ELSE IF brand is B3 or b3
THEN PRINT
"Very nice! These are the models of " << B3 << "."
| Enter | Model |
-----------------------------------------
| PM31 | HuaWei P60 Pro |
| PM32 | HuaWei Mate X3 |
| PM33 | HuaWei Nova 11 Pro |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is PM31
THEN PRINT
"You chose " << PM31 << "! "
"Please enter the amount of " << PM31 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM31 << ". "
subtotal = modelAmount * PP31
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM31 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM31 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM32


THEN PRINT
"You chose " << PM32 << "! "
"Please enter the amount of " << PM32 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM32 << ". "
subtotal = modelAmount * PP32
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM32 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM32 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is PM33


THEN PRINT
"You chose " << PM33 << "! "
"Please enter the amount of " << PM33 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << PM33 << ". "
subtotal = modelAmount * PP33
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << PM33 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << PM33 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (PM31, PM32, PM33)"
WHILE repeat again when model is not PM31, PM32, PM33

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (B1, B2, B3)"
WHILE repeat again when brand is not B1 or b1, B2 or b2, B3 or b3

ELSE IF deviceType is B or b
THEN PRINT
"You have chosen tablet!
Which brand would you like?"
INPUT brand
DO
IF brand is B1 or b1
THEN PRINT
"Very nice! These are the models of " << B1 << "."
| Enter | Model |
-----------------------------------------
| TM11 | iPad Pro |
| TM12 | iPad Air |
| TM13 | iPad 10th Gen |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is TM11
THEN PRINT
"You chose " << TM11 << "! "
"Please enter the amount of " << TM11 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM11 << ". "
subtotal = modelAmount * TP11
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM11 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM11 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM12


THEN PRINT
"You chose " << TM12 << "! "
"Please enter the amount of " << TM12 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM12 << ". "
subtotal = modelAmount * TP12
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM12 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM12 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM13


THEN PRINT
"You chose " << TM13 << "! "
"Please enter the amount of " << TM13 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM13 << ". "
subtotal = modelAmount * TP13
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM13 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM13 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (TM11, TM12, TM13)"
WHILE repeat again when model is not TM11, TM12, TM13

ELSE IF brand is B2 or b2
THEN PRINT
"Very nice! These are the models of " << B2 << "."
| Enter | Model |
-----------------------------------------
| TM21 |Samsung Galaxy Tab S9 Ultra|
| TM22 |Samsung Galaxy Tab S9 FE+ |
| TM23 |Samsung Galaxy Tab A9+ |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is TM21
THEN PRINT
"You chose " << TM21 << "! "
"Please enter the amount of " << TM21 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM21 << ". "
subtotal = modelAmount * TP21
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM21 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM21 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM22


THEN PRINT
"You chose " << TM22 << "! "
"Please enter the amount of " << TM22 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM22 << ". "
subtotal = modelAmount * TP22
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM22 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM22 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM23


THEN PRINT
"You chose " << TM23 << "! "
"Please enter the amount of " << TM23 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM23 << ". "
subtotal = modelAmount * TP23
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM23 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM23 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (TM21, TM22, TM23)"
WHILE repeat again when model is not TM21, TM22, TM23

ELSE IF brand is B3 or b3
THEN PRINT
"Very nice! These are the models of " << B3 << "."
| Enter | Model |
-----------------------------------------
| TM31 | HuaWei MatePad Pro |
| TM32 | HuaWei MatePad Air |
| TM33 | HuaWei MatePad |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is TM31
THEN PRINT
"You chose " << TM31 << "! "
"Please enter the amount of " << TM31 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM31 << ". "
subtotal = modelAmount * TP31
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM31 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM31 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM32


THEN PRINT
"You chose " << TM32 << "! "
"Please enter the amount of " << TM32 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM32 << ". "
subtotal = modelAmount * TP32
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM32 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM32 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is TM33


THEN PRINT
"You chose " << TM33 << "! "
"Please enter the amount of " << TM33 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << TM33 << ". "
subtotal = modelAmount * TP33
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << TM33 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << TM33 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (TM31, TM32, TM33)"
WHILE repeat again when model is not TM31, TM32, TM33

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (B1, B2, B3)"
WHILE repeat again when brand is not B1 or b1, B2 or b2, B3 or b3

ELSE IF deviceType is C or c
THEN PRINT
"You have chosen smartwatch!
Which brand would you like?"
INPUT brand
DO
IF brand is B1 or b1
THEN PRINT
"Very nice! These are the models of " << B1 << "."
| Enter | Model |
-----------------------------------------
| WM11 | Apple Watch Series 9 |
| WM12 | Apple Watch Ultra 2 |
| WM13 | Apple Watch SE |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is WM11
THEN PRINT
"You chose " << WM11 << "! "
"Please enter the amount of " << WM11 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM11 << ". "
subtotal = modelAmount * WP11
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM11 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM11 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM12


THEN PRINT
"You chose " << WM12 << "! "
"Please enter the amount of " << WM12 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM12 << ". "
subtotal = modelAmount * WP12
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM12 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM12 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM13


THEN PRINT
"You chose " << WM13 << "! "
"Please enter the amount of " << WM13 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM13 << ". "
subtotal = modelAmount * WP13
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM13 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM13 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (WM11, WM12, WM13)"
WHILE repeat again when model is not WM11, WM12, WM13

ELSE IF brand is B2 or b2
THEN PRINT
"Very nice! These are the models of " << B2 << "."
| Enter | Model |
-----------------------------------------
| WM21 | Samsung Galaxy Watch6 |
| WM22 | Samsung Galaxy Classic |
| WM23 | Samsung Galaxy Watch4 |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is WM21
THEN PRINT
"You chose " << WM21 << "! "
"Please enter the amount of " << WM21 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END
ELSE IF modelAmount is more than 0
THEN PRINT
"You have bought " << modelAmount << " of " << WM21 << ". "
subtotal = modelAmount * WP21
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM21 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM21 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM22


THEN PRINT
"You chose " << WM22 << "! "
"Please enter the amount of " << WM22 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM22 << ". "
subtotal = modelAmount * WP22
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END
CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM22 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM22 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM23


THEN PRINT
"You chose " << WM23 << "! "
"Please enter the amount of " << WM23 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM23 << ". "
subtotal = modelAmount * WP23
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM23 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM23 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (WM21, WM22, WM23)"
WHILE repeat again when model is not WM21, WM22, WM23

ELSE IF brand is B3 or b3
THEN PRINT
"Very nice! These are the models of " << B3 << "."
| Enter | Model |
-----------------------------------------
| WM31 | HuaWei Watch 4 Series |
| WM32 | HuaWei Watch GT 4 |
| WM33 | HuaWei Band 8 |
What is your choice?"
INPUT model

model = TOUPPER(model);

DO
IF model is WM31
THEN PRINT
"You chose " << WM31 << "! "
"Please enter the amount of " << WM31 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM31 << ". "
subtotal = modelAmount * WP31
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM31 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM31 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM32


THEN PRINT
"You chose " << WM32 << "! "
"Please enter the amount of " << WM32 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END
ELSE IF modelAmount is more than 0
THEN PRINT
"You have bought " << modelAmount << " of " << WM32 << ". "
subtotal = modelAmount * WP32
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM32 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM32 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE IF model is WM33


THEN PRINT
"You chose " << WM33 << "! "
"Please enter the amount of " << WM33 << " would you like to buy."
INPUT modelAmount

DO
IF modelAmount is 0
THEN PRINT
"Since you have not purchase any product of the store.
Therefore you cannot purchase any add-ons available.
Thank you for patronage! Please come again."
return 0;
END

ELSE IF modelAmount is more than 0


THEN PRINT
"You have bought " << modelAmount << " of " << WM33 << ". "
subtotal = modelAmount * WP33
PRINT
"The subtotal of the product is RM" << subtotal << setprecision(2) << fixed << ". "

PRINT
"Here are the add-ons with prices 40% off:
| Enter | Add-on | Price |
-------------------------------------------------------------------------------------
| A1 |Brand new power adapter with type-C cable | RM154 |
| A2 |New high quality wireless on-ear headphones | RM1,200 |
| A3 |New high quality wireless earbuds | RM132 |
| A4 |Silicone phone case | RM144 |
| A5 |Magnetic wireless charger | RM132 |
| A6 |Portable bluetooth speaker | RM900 |
| N |No add-on purchased |
Which add-on would you consider?"
DO
INPUT addOn

addOn = TOUPPER(addOn);
SWITCH(addOn)
CASE "A1":
PRINT
"You chose " << A1 << "! "
//Calculate the total price with add-on
totalPrice = subtotal + AP1
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A1 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A2":
PRINT
"You chose " << A2 << "! "
totalPrice = subtotal + AP2
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A2 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END
CASE "A3":
PRINT
"You chose " << A3 << "! "
totalPrice = subtotal + AP3
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A3 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A4":
PRINT
"You chose " << A4 << "! "
totalPrice = subtotal + AP4
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A4 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A5":
PRINT
"You chose " << A5 << "! "
totalPrice = subtotal + AP5
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A5 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "A6":
PRINT
"You chose " << A6 << "! "
totalPrice = subtotal + AP6
PRINT
"Product purchased: " << WM33 << endl;
"Add-on purchased: " << A6 << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
BREAK
END

CASE "N":
PRINT
"You did not purchase an add-on."
totalPrice = subtotal
PRINT
"Product purchased: " << WM33 << endl;
"No add-on purchased." << endl;
"The total price is " << totalPrice << ". "
"Thank you for patronage! Please come again."
END

DEFAULT:
PRINT
"Opps! Invalid input. Please try again.
(A1, A2, A3, A4, A5, A6, N)
WHILE repeat again when addOn is not A1, A2, A3, A4, A5, A6, N

ELSE
THEN PRINT "Opps! Invalid input. Please try again."
WHILE repeat again when modelAmount is not more than and equal to 0

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (WM31, WM32, WM33)"
WHILE repeat again when model is not WM31, WM32, WM33

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (B1, B2, B3)
WHILE repeat again when brand is not B1 or b1, B2 or b2, B3 or b3

ELSE
THEN PRINT "Opps! Invalid input. Please try again. (A, B, C)"
//Repeat again
WHILE repeat again when deviceType is not A or a, B or b, C or c

END

You might also like