Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

D. (4 points) A movie theater sells 4 different priced tickets: youth, adult, se

ID: 3826996 • Letter: D

Question

D. (4 points) A movie theater sells 4 different priced tickets: youth, adult, senior, student. Below is a matlab function called "tickets" that has 2 vectors as arguments: the first vector has the price of each type of ticket in dollars and the second vector has the of each type of ticket sold for a group of customers. The function returns the total ticket income and the total number of tickets sold. function income cnt l tickets price numTickets income price numTickets; income sum (income) cnt sum (num rickets) end [total Income totalCount] tickets [3 10 6 5 [1 3 1 21) total Income 49 total count. 7 a. The theater has decided to add a special discount. Customers get a percentage off equal to the number of people in their party. Add code to the above function for that modification. b. The theater is also trying a different special discount. If there are more than 5 customers of a type (youth, adult, senior, student), one customer of that type gets in free. Create a test table for each of these seperate modifications, and create two matlab functions to solve the problem. Design will be done in lecture or lab. Sample Data Expected Result verified? Test Case (manually calculate)

Explanation / Answer

Part a Matlab Program

function [income,cnt] = tickets_Parta(price,numTickets)
   income = price.*numTickets;
   income = sum(income);
   cnt = sum(numTickets);
   income = income*(100-cnt)/100; % Comuting the income after discount
end

Testing the Program

>> price = [3 10 6 5];
>> [income,cnt] = tickets_Parta(price,[1 3 1 2])

income =

   45.5700


cnt =

     7

>> [income,cnt] = tickets_Parta(price,[2 5 3 7])

income =

   90.4700


cnt =

    17

>> [income,cnt] = tickets_Parta(price,[ 1 1 1 1])

income =

   23.0400


cnt =

     4

>> [income,cnt] = tickets_Parta(price,[1 0 0 0])

income =

    2.9700


cnt =

     1

>> [income,cnt] = tickets_Parta(price,[8 3 1 0])

income =

   52.8000


cnt =

    12

Table for Part a)

Ticket Price = [3 10 6 5]

Matlab Program for Part b)

function [income,cnt] = tickets_Partb(price,numTickets)
   income = price.*numTickets;
   income = sum(income);
   cnt = sum(numTickets);
   income = income - sum((numTickets>5).*price);% Comuting the income after free ticket
end

Testing of the function OUTPUTS

>> price = [3 10 6 5];
>> [income,cnt] = tickets_Partb(price,[1 3 1 2])

income =

    49


cnt =

     7

>> [income,cnt] = tickets_Partb(price,[6 4 3 8])

income =

   108


cnt =

    21

>> [income,cnt] = tickets_Partb(price,[8 8 8 8])

income =

   168


cnt =

    32

>> [income,cnt] = tickets_Partb(price,[6 0 0 0])

income =

    15


cnt =

     6

>> [income,cnt] = tickets_Partb(price,[ 5 5 5 5])

income =

   120


cnt =

    20

>>

Table for Part b)

Test Case Sample DATA Expected Result Verified [1 3 1 2] 45.57 45.57 yes [2 5 3 7] 90.47 90.47 yes [ 1 1 1 1] 23.04 23.04 yes [1 0 0 0] 2.97 2.97 yes [8 3 1 0] 52.80 52.80 yes