Electronicdevice Pseudocode On Docs
Electronicdevice Pseudocode On Docs
//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
FLOAT
//Initialise smartphone prices
PP11 = 6499
PP12 = 4899
PP13 = 4299
PP21 = 5699
PP22 = 4499
PP23 = 6799
PP31 = 4699
PP32 = 8888
PP33 = 2599
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
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
//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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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