Question

In: Computer Science

Q66. Two stores (A, B) both sell one product. The sales data for each day is...

Q66. Two stores (A, B) both sell one product. The sales data for each day is shown in the following table (use variable T for the table). The first column is used to identify the stores (A and B); the 2nd column is the unite price of the product on that day; the 3rd column is the number of sold product on each day.

store price

Price

count

A

25

10

A

26

9

B

20

18

B

22

18

(1) Get a sub-table (T2) which includes only the sales data for store A (all three columns).

(2) Calculate average (unit) price, maximum price for store A.

(3) Calculate the total sale amount for store A. That is, 25*10 + 26*9 + 20*18 + ... + 22*18. Solve this without using loop and using loop.

I need help to solve this in MATLAB programming...please

Solutions

Expert Solution

Without using Forloop



% sample data
stores = ['A'; 'A';'B';'A';'B';'A';'B'];
Price = [25; 26; 20; 22; 24; 30; 40];
count = [10; 9; 18; 7; 6; 18;12];
T = table(stores, Price, count)

% slicing stores with A
T2 = T(T.stores=='A',:)
% calculating average Price of store A
avgUnitPrice = mean(T2.Price);
% calculating maximum Price of store A
maxPriceStoreA = max(T2.Price);
% calculating total sales of store A
totalSaleOfStoreA = sum(T2.Price .* T2.count);


% printing data
fprintf("Average Price of store A     : %f\n", avgUnitPrice);
fprintf("Maximum price for store A    : %f\n", maxPriceStoreA);
fprintf("Total Sale Amount of store A : %f\n", totalSaleOfStoreA);


Code

Output

Using For Loop



% sample data
stores = ['A'; 'A';'B';'A';'B';'A';'B'];
Price = [25; 26; 20; 22; 24; 30; 40];
count = [10; 9; 18; 7; 6; 18;12];
T = table(stores, Price, count)

% slicing stores with A
T2 = T(T.stores=='A',:)

avgUnitPrice = 0;
maxPriceStoreA = T2.Price(1);
totalSaleOfStoreA = 0;
sumOfPrices = 0;

% calculating  sumOfPrices, maxPrice, totalSales
% using for loop
for row = 1:length(T2.stores)
    
    % slicing and summing values
    sumOfPrices = sumOfPrices + T2(row,:).Price;
    if maxPriceStoreA < T2(row,:).Price
        maxPriceStoreA = T2(row,:).Price;
    end
    totalSaleOfStoreA = totalSaleOfStoreA + T2(row,:).Price*T2(row,:).count;
    
end

% calculating average
avgUnitPrice = sumOfPrices/length(T2.stores);

% printing data
fprintf("Average Price of store A     : %f\n", avgUnitPrice);
fprintf("Maximum price for store A    : %f\n", maxPriceStoreA);
fprintf("Total Sale Amount of store A : %f\n", totalSaleOfStoreA);


Code

Output


Related Solutions

You manufacture two products, A and B, each of which you sell for $1 profit. Product...
You manufacture two products, A and B, each of which you sell for $1 profit. Product A requires 5 blobs and 3 globs, and product B requires 3 blobs and 5 globs. Your supplier has 120 blobs and 120 globs available. Use the Excel Solver (or graphical analysis) to answer the following questions. 9. If the profit on B increases to $2, can you increase profit by trading 30 blobs for 30 globs? 10. As the profit on B changes...
You manufacture two products, A and B, each of which you sell for $1 profit. Product...
You manufacture two products, A and B, each of which you sell for $1 profit. Product A requires 5 blobs and 3 globs, and product B requires 3 blobs and 5 globs. Your supplier has 120 blobs and 120 globs available. Use the Excel Solver (or graphical analysis) to answer the following questions. 17. Can you obtain more blobs and globs for product B by producing negative quantities of product A?
Q7: There are two retail stores – both of them have sales of $ 200000 annually...
Q7: There are two retail stores – both of them have sales of $ 200000 annually and annual cost of goods sold is $150000 in each of the stores. Labor and other expenses are $10000 annually in each of the two stores. The only difference between the two stores is that the normal inventory or stock of goods in Store A is $800000, while the normal inventory or stock of goods in store B is $400000. Estimate the difference in...
We have 3,000 Units of product to sell over a five day period. From historical sales...
We have 3,000 Units of product to sell over a five day period. From historical sales data, we have estimated the following demand curves P=price/unit in $ Q=number of units sold Day 1: P=10-0.01Q valid for prices between $3and $8. Day 2: same as Day 1 Day 3: P= 15-0.01Q valid for prices between $6 and $10 Day 4 P=20-0.01Q valid for prices between $6 and $12 Day 5: same as Day 1 1. The revenue maximizing price for day...
) 123 Corporation sells two products Product A and product B which sell in a 3:2...
) 123 Corporation sells two products Product A and product B which sell in a 3:2 ratio. Product A has a variable cost of $65 per unit and sells for $70. 123 Corporation has fixed expenses of $140,000. When 123 corporations sells 25,000 units they have an operating income of $20,000. a) What is the contribution margin on Product B? ANS: b) Assuming variables costs of $80, what is the sales price of product B? Ans: c) Prepare a contribution...
Two grocery stores compete against each other in a community. Both are considering an increase in...
Two grocery stores compete against each other in a community. Both are considering an increase in advertising expenditures. Their interdependent alternatives are described by the payoff matrix below (first entry is for firm 1).                                                                                         Firm 2 Advertise Don’t Advertise Firm 1 Advertise (6, 4) (9, 5) Don’t Advertise (3, 7) (8, 6) i. Determine whether each firm has a dominant strategy and, if it does, identify the strategy. Firm 1: _________________________________; Firm 2: _______________________________ ii. Determine the Nash equilibrium
Consider the following game in which two firms A and B sell computing product and are...
Consider the following game in which two firms A and B sell computing product and are deciding whether to undertake advertising campaigns. The possible outcomes of this simultaneous one-shot game are illustrated by the payoff matrix (annual profit payoffs in millions). Note: Firm A's payoffs appear first in the payoff pairs: Firm A Firm B Strategy Advertise Don't Advertise Advertise 10, 5 15, 0 Don't advertise 6, 8 20, 2 Use the payoff matrix to answer the questions below. a....
The following data are for the two products produced by Shakti Company. Product A Product B...
The following data are for the two products produced by Shakti Company. Product A Product B Direct materials $ 15 per unit $ 24 per unit Direct labor hours 0.3 DLH per unit 1.6 DLH per unit Machine hours 0.1 MH per unit 1.2 MH per unit Batches 125 batches 225 batches Volume 10,000 units 2,000 units Engineering modifications 12 modifications 58 modifications Number of customers 500 customers 400 customers Market price $ 30 per unit $ 120 per unit...
The following data are for the two products produced by Tadros Company. Product A Product B...
The following data are for the two products produced by Tadros Company. Product A Product B Direct materials $ 14 per unit $ 25 per unit Direct labor hours 0.6 DLH per unit 1.5 DLH per unit Machine hours 0.5 MH per unit 1.1 MH per unit Batches 100 batches 200 batches Volume 10,000 units 2,000 units Engineering modifications 10 modifications 50 modifications Number of customers 500 customers 400 customers Market price $ 34 per unit $ 120 per unit...
The following data are for the two products produced by Tadros Company. Product A Product B...
The following data are for the two products produced by Tadros Company. Product A Product B Direct materials $ 14 per unit $ 26 per unit Direct labor hours 0.3 DLH per unit 1.6 DLH per unit Machine hours 0.2 MH per unit 1.2 MH per unit Batches 115 batches 230 batches Volume 10,000 units 2,000 units Engineering modifications 10 modifications 50 modifications Number of customers 500 customers 400 customers Market price $ 35 per unit $ 120 per unit...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT