(a) Based on the description above, write a pseudocode to calculate and display the total discount in percentage (%) and the total price a customer needs to pay after discount in RM – if applicable. (b) John plans to shop N items during the promotion period. Assume that the price per unit for every item is given in a vector called P, and the quantity to be purchased per item is given in vector M. The length of vectors P and M is N. The following Table Ql illustrates the purchase of John. Table Q1 Product Price per unit (P) Quantity (M) Milk 5 10 Chocolate bar Coca Cola Can AA batteries Power bank 7 1 2 2 15 1 195 10 Write the MATLAB code to implement John's purchase based on your pseudocode in (a). The following code is given; % Vectors containing John's purchase P = [5, 7, 2, 15, 195]; м 3 [10, 1, 2, 1, 10]; An example of expected output display of your program is as follows; Total discount = 25 % Total price after discount = RM 1519.5

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Question 1
An online shopping platform is going to organize a sales promotion for the 2021-year end. During the
promotion period, a discount of 10% will be given for each item purchased if the number of items being
purchased is at least 5 items. On top of that, if the total sum of purchase if RM 1,000 or more, an
additional discount of 15% will be given. A customer can purchase different items and different number
of units of the same item.
(a) Based on the description above, write a pseudocode to calculate and display the total discount
in percentage (%) and the total price a customer needs to pay after discount in RM – if
applicable.
(b) John plans to shop N items during the promotion period. Assume that the price per unit for
every item is given in a vector called P, and the quantity to be purchased per item is given in
vector M. The length of vectors P and M is N. The following Table Ql illustrates the purchase
of John.
Table Q1
Product
Milk
Price per unit (P).
Quantity (M)
5
10
1
2
Chocolate bar
Coca Cola Can
2
AA batteries
15
1
Power bank
195
10
Write the MATLAB code to implement John's purchase based on your pseudocode in (a). The
following code is given;
% Vectors containing John's purchase
P = [5, 7, 2, 15, 195];
M = [10, 1, 2, 1, 10];
An example of expected output display of your program is as follows;
Total discount = 25 %
Total price after discount = RM 1519.5
Transcribed Image Text:Question 1 An online shopping platform is going to organize a sales promotion for the 2021-year end. During the promotion period, a discount of 10% will be given for each item purchased if the number of items being purchased is at least 5 items. On top of that, if the total sum of purchase if RM 1,000 or more, an additional discount of 15% will be given. A customer can purchase different items and different number of units of the same item. (a) Based on the description above, write a pseudocode to calculate and display the total discount in percentage (%) and the total price a customer needs to pay after discount in RM – if applicable. (b) John plans to shop N items during the promotion period. Assume that the price per unit for every item is given in a vector called P, and the quantity to be purchased per item is given in vector M. The length of vectors P and M is N. The following Table Ql illustrates the purchase of John. Table Q1 Product Milk Price per unit (P). Quantity (M) 5 10 1 2 Chocolate bar Coca Cola Can 2 AA batteries 15 1 Power bank 195 10 Write the MATLAB code to implement John's purchase based on your pseudocode in (a). The following code is given; % Vectors containing John's purchase P = [5, 7, 2, 15, 195]; M = [10, 1, 2, 1, 10]; An example of expected output display of your program is as follows; Total discount = 25 % Total price after discount = RM 1519.5
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education