Question
Write the pseudocode for the following scenario:
A shop owner needs to increase the prices for all his stock by 6% to keep up with inflation. He stores
the product names in one array called “Product” which has 5 elements. This array stores the names
of the products.
PRODUCT ARRAY
Rice Sugar Tea Porridge Milk
He stores the prices of the corresponding items (in Rands) in a parallel array called “Price”.
PRICE ARRAY
25.99 22.50 12.00 20.00 18.50
i.e., Rice - R25.99
Sugar - R22.50
Tea - R12.00
Porridge - R20.00
Milk - R18.50
• Declare and populate both arrays with the product names and their corresponding
prices (use a loop).
(9)
• Calculate and add 6% to the existing price for each product. Store the new prices in the
“Price” array.
(5)
• Display the product name with the new corresponding prices. (4)
• Write descriptive comments in the pseudocode.
A shop owner needs to increase the prices for all his stock by 6% to keep up with inflation. He stores
the product names in one array called “Product” which has 5 elements. This array stores the names
of the products.
PRODUCT ARRAY
Rice Sugar Tea Porridge Milk
He stores the prices of the corresponding items (in Rands) in a parallel array called “Price”.
PRICE ARRAY
25.99 22.50 12.00 20.00 18.50
i.e., Rice - R25.99
Sugar - R22.50
Tea - R12.00
Porridge - R20.00
Milk - R18.50
• Declare and populate both arrays with the product names and their corresponding
prices (use a loop).
(9)
• Calculate and add 6% to the existing price for each product. Store the new prices in the
“Price” array.
(5)
• Display the product name with the new corresponding prices. (4)
• Write descriptive comments in the pseudocode.
Answers
Answer
thanks
Answered by
Bot
DECLARE Product ARRAY with 5 elements
DECLARE Price ARRAY with 5 elements
FOR i = 0 TO 4 //Populate arrays with input from user
PRINT "Enter product name: "
INPUT Product[i]
PRINT "Enter product price: "
INPUT Price[i]
ENDFOR
FOR i = 0 TO 4 //Add 6% to each price
Price[i] = Price[i] + (Price[i] * 0.06)
ENDFOR
FOR i = 0 TO 4 //Display product name with new price
PRINT Product[i] + " - R" + Price[i]
ENDFOR
DECLARE Price ARRAY with 5 elements
FOR i = 0 TO 4 //Populate arrays with input from user
PRINT "Enter product name: "
INPUT Product[i]
PRINT "Enter product price: "
INPUT Price[i]
ENDFOR
FOR i = 0 TO 4 //Add 6% to each price
Price[i] = Price[i] + (Price[i] * 0.06)
ENDFOR
FOR i = 0 TO 4 //Display product name with new price
PRINT Product[i] + " - R" + Price[i]
ENDFOR
Answered by
Bot
You're welcome! Let me know if you need any help with anything else.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.