~~~~~~~~~~~~~~~~~~~~Please use MATLAB to answer the following question - Thank y
ID: 3861916 • Letter: #
Question
~~~~~~~~~~~~~~~~~~~~Please use MATLAB to answer the following question - Thank you!!~~~~~~~~~~~~~~
Problem 1. Use the data in the lab folder at the eLc pricelist.xlxs to do the following. The table shows the product ID, unit price and order quantity of a list of twenty products. The Total Price is based on a store promotion of 10% discount on all purchases. Write a function call pricelist that will do the following: 1. Use the xlsread function to read the portion of the file you want, 2. Compute all the needed values and 3. Use ONLY the fprintf function to format your printing to look just like below Total Price Product ID Unit Price Quantity 23.99 496.59 23 12.56 135.65 12 65.89 1956.93 33 102.79 1110.13 12 34.89 188.41 23.99 259.09 12 23.68 404.93 19 98.99 3741.82 42 98.89 1958.02 22 76.39 2543.79 10 37 45.89 1775.94 11 43 43.99 435.50 12 11 23.88 451.33 13 21 23.99 690.91 14 32 19.99 269.86 15 15 26.99 1238.84 16 51 2539.80 112.88 17 25 29.88 457.16 18 17 237.52 13.89 19 19 1949.06 56.99 20 38Explanation / Answer
%function pricelist
clc;
clear all;
data=xlsread('pricelist.xlxs',-1); % Read Specific Portaion of Data From .xlxs file.
% Please Select Data from Excel File and Than Press ok in matlab dialog box.
data(:,4)=(data(:,2).*data(:,3)).*0.9; % calculate 10% discount. The acutal value is (100-10)% of the value
fprintf('Product ID Quantity Unit Price Total Price($) ');
fprintf('---------- -------- ---------- -------------- ');
for i=1:size(data,1)
fprintf('%d %d $ %.2f $ %.2f ',data(i,1),data(i,3),data(i,2),data(i,4));
end
% Output-------------------------------------
Select the portion you want to display from your xlxs file
Product ID Quantity Unit Price Total Price($)
---------- -------- ---------- --------------
8 42 $ 98.99 $ 3741.82
9 22 $ 98.89 $ 1958.02
10 37 $ 76.39 $ 2543.79
11 43 $ 45.89 $ 1775.94
12 11 $ 43.99 $ 435.50
13 21 $ 23.88 $ 451.33
14 32 $ 23.99 $ 690.91
15 15 $ 19.99 $ 269.86
16 51 $ 26.99 $ 1238.84
17 25 $ 112.88 $ 2539.80
18 17 $ 29.88 $ 457.16
19 19 $ 13.89 $ 237.52
>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.