Professional Documents
Culture Documents
Friday, June 26, 2020 5:57 PM: LBB Page 1
Friday, June 26, 2020 5:57 PM: LBB Page 1
2210_w20_PM_22
Lbb Page 1
Lbb Page 2
Lbb Page 3
//Use arrays to store item code, description and price
ShoppingCart=[]
DECLARE Item_Code[17]: STRING =["A1", "A2", "B1", "B2", "B3", "C1",
"C2", "C3", "D1", "D2", "E1","E2","E3", "F1", "F2", "G1", "G2"]
Lbb Page 4
DECLARE Price[17]: REAL= [75.00, 150.00, 79.99, 149.99, 299.99,
49.99, 89.99, 129.99, 59.99, 119.99, 49.99, 89.99, 129.99, 50.00,
100.00, 100.00, 175.00]
CONSTANT Basic_Price=200
DECLARE Computer-Price, Case_Price, RAM_Price, MHDD_Price: REAL
// Allow a customer to choose one case, one RAM and one HDD
FOR Index = 0 TO 7
IF Case_Code=Item_Code[Index] THEN
Case_Price <-- Price[Index]
ShoppingCart.append(Description[index])
Lbb Page 5
Computer_Price<-- Basic_Price + Case_Price + RAM_Price +
MHDD_Price
PRINT "Computer price = " , Computer_Price
Python Code:
Item_Code=["A1", "A2", "B1", "B2", "B3", "C1", "C2", "C3", "D1", "D2",
"E1","E2","E3", "F1", "F2", "G1", "G2"]
Description= ["Compact", "Tower", "8GB", "16GB", "32GB", "1 TB HDD",
"2 TB HDD", "4 TB HDD", "240 GB SSD", "480 GB SSD", "1 TB HDD", "2
TB HDD", "4 TB HDD", "DVD/Blu-Ray Player", "DVD/Blu-Ray Re-
Writer", "Standard Version", "Professional Version"]
Price= [75.00, 150.00, 79.99, 149.99, 299.99, 49.99, 89.99, 129.99,
59.99, 119.99, 49.99, 89.99, 129.99, 50.00, 100.00, 100.00, 175.00]
Basic_Price=200
print("Here is the list of Computer Case")
for Index in range(2):
print(Item_Code[Index], Description[Index], Price[Index])
Lbb Page 6
MHDD_Code=str(input("Enter Item code for Main Hard Disc Drive: "))
Count_Addition=0
PRINT "Do you want to purchase a solid state drvie (Yes/No) :"
INPUT Choice
IF Choice="Yes" THEN
PRINT "Here is the list of solid state drive "
FOR Index= 8 TO 9
PRINT Item_Code[Index], Description[index], Price[Index]
NEXT Index
PRINT "Enter item code of selected solid state drive "
INPUT SSD_Code
WHILE NOT (SSD_Code=Item_Code[8] or SSD_Code=Item_Code[9]) DO
PRINT "Error! Invalid item code for SSD is entered, try
again"
INPUT SSD_Code
ENDWHILE
Lbb Page 7
ENDWHILE
ENDIF
PRINT "Do you want to purchase a solid state drvie (Yes/No) :"
INPUT Choice
IF Choice="Yes" THEN
PRINT "Here is the list of solid state drive "
FOR Index= 8 TO 9
PRINT Item_Code[Index], Description[index], Price[Index]
NEXT Index
PRINT "Enter item code of selected solid state drive "
INPUT SSD_Code
WHILE NOT (SSD_Code=Item_Code[8] or SSD_Code=Item_Code[9]) DO
PRINT "Error! Invalid item code for SSD is entered, try
again"
INPUT SSD_Code
ENDWHILE
ENDIF
Lbb Page 8