Q1. Hamid is designing a computerized system for ABC Grocery shop.
(a) Write program code for a subroutine INPUT( )
That takes ItemID as STRING parameter
Inputs ID from the user and assigns it to the ItemID so that it can be updated.
(b) Write program code for a subroutine Expensive that
Uses a precondition loop to input 10 Prices
Calculates and outputs the price of the most Expensive Item and Least expensive Item
Calculates and returns the Average price
(c) Write a subroutine Validate( ) that
Validates the parameter ItemID according to the following criterion
o Must be 9 characters long
o Must Start with “ABC”
o Last 4 characters must be digits
o Remaining characters should be lower case letters
Return TRUE if valid, otherwise return FALSE
(d) Write a subroutine ApplyDiscount( )
Takes ItemId as parameter
Assume Price is a global variable
Local variable TodayDate is assigned Today’s Date using a built-in function
Item IDs are divided into the following categories
ItemID ending with Category DiscountRate
7 Décor 10%
8 Stationery 20%
9 Dairy 15%
Use Case Structure to apply the appropriate discount rate and calculate the
DiscountedPrice.
Output DiscountedPrice, category and TodayDate
( e) Hamid writes a subroutine TEST( ) to test some of the modules.
Declare local variable ItemID as String
Calls INPUT
Calls validate to check if ItemID is valid or Invalid.
If it is Valid Call ApplyDiscount, otherwise display an error message
Write the program code for TEST()