Note: ‘=’ has been used in place of the assignment operator as I could not find the assignment arrow
on my keyboard
QUESTION 1 PART A PSEUDOCODE
DECLARE Choice: INTEGER
DECLARE Hours, Charge: REAL
INPUT “Enter 1 for Motorcycle, 2 for Car, 3 for Van”, Choice
INPUT “Enter the number of hours”, Hours
CASE Choice OF
1 : Charge = 50 * Hours
2 : Charge = 80 * Hours
3 : Charge = 150 * Hours
OTHERWISE : OUTPUT “Invalid choice of vehicle”
ENDCASE
OUTPUT “The charge is ”, Charge, “ Rupee”
QUESTION 1 PART B PSEUDOCODE
DECLARE Choice, Count, ParkingSpaces, InvalidCount: INTEGER
DECLARE Hours, Charge, Total: REAL
ParkingSpaces = 75
For Count = 1 To 75 Step 1
INPUT “Enter 1 for Motorcycle, 2 for Car, 3 for Van”, Choice
INPUT “Enter the number of hours”, Hours
CASE Choice OF
1 : Charge = 50 * Hours
2 : Charge = 80 * Hours
3 : Charge = 150 * Hours
OTHERWISE : OUTPUT “Invalid choice of vehicle”
Charge = 0
InvalidCount = InvalidCount + 1
ENDCASE
Total = Total + Charge
ENDFOR
ParkingSpaces = ParkingSpaces - InvalidCount
OUTPUT “The total charge is ”, Total, “ Rupee for ”, ParkingSpaces, “ parking spaces”
QUESTION 1 PART C PSEUDOCODE
DECLARE Choice, Count, ParkingSpaces, InvalidCount: INTEGER
DECLARE Hours, Charge, Total: REAL
REPEAT
INPUT “Enter the number of parking spaces occupied”, ParkingSpaces
UNTIL ParkingSpaces >= 0 AND ParkingSpaces <= 75
For Count = 1 To ParkingSpaces Step 1
INPUT “Enter 1 for Motorcycle, 2 for Car, 3 for Van”, Choice
INPUT “Enter the number of hours”, Hours
CASE Choice OF
1 : Charge = 50 * Hours
2 : Charge = 80 * Hours
3 : Charge = 150 * Hours
OTHERWISE : OUTPUT “Invalid choice of vehicle”
Charge = 0
InvalidCount = InvalidCount + 1
ENDCASE
Total = Total + Charge
ENDFOR
ParkingSpaces = ParkingSpaces - InvalidCount
OUTPUT “The total charge is ”, Total, “ Rupee for ”, ParkingSpaces, “ parking spaces”
QUESTION 1 PART D PSEUDOCODE
DECLARE Choice, Count, ParkingSpaces: INTEGER
DECLARE Hours, Charge, Total: REAL
REPEAT
INPUT “Enter the number of parking spaces occupied”, ParkingSpaces
UNTIL ParkingSpaces >= 0 AND ParkingSpaces <= 75
For Count = 1 To ParkingSpaces Step 1
INPUT “Enter 1 for Motorcycle, 2 for Car, 3 for Van”, Choice
INPUT “Enter the number of hours”, Hours
WHILE Choice >= 1 AND Choice <= 3
CASE Choice OF
1 : Charge = 50 * Hours
2 : Charge = 80 * Hours
3 : Charge = 150 * Hours
ENDCASE
Total = Total + Charge
Choice = 0
ENDWHILE
ENDFOR
OUTPUT “The total charge is ”, Total, “ Rupee for ”, ParkingSpaces, “ parking spaces”
QUESTION 2 PART A PSEUDOCODE
DECLARE Type: INTEGER
DECLARE OriginalPrice, DiscountedPrice: REAL
INPUT “Enter 1 for Electronics, 2 for Clothing, 3 for Household, 4 for Other”, Type
INPUT “Enter the original price”, OriginalPrice
CASE Type OF
1: DiscountedPrice = OriginalPrice * 0.8
OUTPUT “Electronics, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
2: DiscountedPrice = OriginalPrice * 0.85
OUTPUT “Clothing, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
3: DiscountedPrice = OriginalPrice * 0.9
OUTPUT “Household, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
4: DiscountedPrice = OriginalPrice * 0.95
OUTPUT “Other, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
OTHERWISE
OUTPUT “INVALID CHOICE”
ENDCASE
QUESTION 2 PART B PSEUDOCODE
DECLARE Type, TotalItems, Count: INTEGER
DECLARE OriginalPrice, DiscountedPrice: REAL
INPUT “Enter the total number of items to be purchases”, TotalItems
FOR Count = 1 To TotalItems Step 1
INPUT “Enter 1 for Electronics, 2 for Clothing, 3 for Household, 4 for Other”, Type
INPUT “Enter the original price”, OriginalPrice
CASE Type OF
1: DiscountedPrice = OriginalPrice * 0.8
OUTPUT “Electronics, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
2: DiscountedPrice = OriginalPrice * 0.85
OUTPUT “Clothing, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
3: DiscountedPrice = OriginalPrice * 0.9
OUTPUT “Household, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
4: DiscountedPrice = OriginalPrice * 0.95
OUTPUT “Other, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
OTHERWISE
OUTPUT “INVALID CHOICE”
ENDCASE
ENDFOR
PSEUDOCODE FOR QUESTION 2 PART C
DECLARE Type, TotalItems, Count: INTEGER
DECLARE OriginalPrice, DiscountedPrice, GrandTotal: REAL
INPUT “Enter the total number of items to be purchases”, TotalItems
FOR Count = 1 To TotalItems Step 1
INPUT “Enter 1 for Electronics, 2 for Clothing, 3 for Household, 4 for Other”, Type
INPUT “Enter the original price”, OriginalPrice
CASE Type OF
1: DiscountedPrice = OriginalPrice * 0.8
OUTPUT “Electronics, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
2: DiscountedPrice = OriginalPrice * 0.85
OUTPUT “Clothing, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
3: DiscountedPrice = OriginalPrice * 0.9
OUTPUT “Household, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
4: DiscountedPrice = OriginalPrice * 0.95
OUTPUT “Other, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
OTHERWISE
OUTPUT “INVALID CHOICE”
ENDCASE
ENDFOR
OUTPUT “The Grand Total is ”, GrandTotal, “ Rupee”
PSEUDOCODE FOR QUESTION 2 PART D
DECLARE Type, TotalItems, Count: INTEGER
DECLARE Promo: STRING
DECLARE OriginalPrice, DiscountedPrice, GrandTotal: REAL
INPUT “Enter the total number of items to be purchases”, TotalItems
FOR Count = 1 To TotalItems Step 1
INPUT “Enter 1 for Electronics, 2 for Clothing, 3 for Household, 4 for Other”, Type
INPUT “Enter the original price”, OriginalPrice
CASE Type OF
1: DiscountedPrice = OriginalPrice * 0.8
OUTPUT “Electronics, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
2: DiscountedPrice = OriginalPrice * 0.85
OUTPUT “Clothing, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
3: DiscountedPrice = OriginalPrice * 0.9
OUTPUT “Household, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
4: DiscountedPrice = OriginalPrice * 0.95
OUTPUT “Other, Original Price ”, OriginalPrice, “, Discounted Price ”, DiscountedPrice
GrandTotal = GrandTotal + DiscountedPrice
OTHERWISE
OUTPUT “INVALID CHOICE”
ENDCASE
ENDFOR
OUTPUT “The Grand Total is ”, GrandTotal, “ Rupee”
INPUT “Enter the promo code”, Promo
IF Promo = “highbrow”
THEN
GrandTotal = GrandTotal * 0.9
OUTPUT “The discounted total is”, GrandTotal
ELSE
OUTPUT “INVALID PROMO CODE”
ENDIF
QUESTION 3 PART A
DECLARE NameList: ARRAY[1:30] OF STRING
DECLARE Count: INTEGER
FOR Count = 1 To 30 Step 1
INPUT “Enter student name”, NameList[Count]
ENDFOR
QUESTION 3 PART B
DECLARE NameList: ARRAY[1:30] OF STRING
DECLARE Count: INTEGER
FOR Count = 1 To 30 Step 1
REPEAT
INPUT “Enter student name”, NameList[Count]
UNTIL NameList[Count] <> “”
ENDFOR
QUESTION 3 PART C
DECLARE Name: STRING
INPUT “Enter name to be found ”, Name
FOR Count = 1 To 30 Step 1
IF NameList[Count] = Name
THEN
OUTPUT “Name found at index ”, Count
ENDIF
ENDFOR