In: Computer Science
A restaurant sells packs of chicken nuggets in various denominations. Using octave, Write a script that prompts the user for a vector of the available pack denominations. The script should then prompt the user for a vector of quantities of each denomination to be purchased. Finally, the script should calculate and print the total number of chicken nuggets that would be obtained from the purchase. Hint: Note that if you multiply (in the linear algebra sense) a 1 × n row vector and an n × 1 column vector you obtain a scalar: h a1 a2 a3 · · · an i b1 b2 b3 . . . bn = a1b1 + a2b2 + a3b3 + · · · anbn. Sample output: Enter the denominations in which chicken nuggets are available: [ 6 9 20 ] Enter the quantity of each denomination to be purchased: [ 1 1 1 ] The total number of chicken nuggets purchased is 35 Enter the denominations in which chicken nuggets are available: [ 4 10 50 8 ] Enter the quantity of each denomination to be purchased: [ 2 0 1 0 ] The total number of chicken nuggets purchased is 58. Also, use disp to print entire vectors of numbers.
total = input("enter no of denominations available")
denominations = []
quantity = []
i = 0;
while(i <= total)
i = i+1;
denominations(i) = input('enter denomination:');
end
i = 0;
while(i <= total)
i = i+1;
quqntity(i) = input('enter denomination:');
end
quantity = reshape(quantity,[],1)
c = denominations * quantity
output = ["The total number of chicken nuggets purchased is
",num2str(c)]
disp(output)
If you have any doubts please comment and please don't dislike.