Question

In: Computer Science

A restaurant sells packs of chicken nuggets in various denominations. Using octave, Write a script that...

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.

Solutions

Expert Solution

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.


Related Solutions

Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three...
Using MATLAB or Octave, Write a script that prompts the user for the coordinates of three points A, B, and C, namely (xA, yA), (xB, yB), (xC, yC), forming a triangle, storing each in a variable (for a total of 6 variables). The script should then calculate the centroid G = (xG, yG) using xG = xA+xB+xC 3 and yG = yA+yB+yC 3 , storing each in a variable. Finally, the script should print all four points. Sample output: Enter...
Using MATLAB or Octave, Write a script that prompts the user for a multiplier, storing it...
Using MATLAB or Octave, Write a script that prompts the user for a multiplier, storing it in the variable fMultiplier. The script should them prompt the user for a number, storing it in the variabl fIn. The script should then calculate the product of these two variables, saving the result to another variable fOut, and printing it. The script should then repeat the prompt for fIn, calculation, and output twice more, using the same variable fIn and fOut all three...
Using MATLAB or Octave, Write a script that prompts the user for a minimum and maximum...
Using MATLAB or Octave, Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer value: 20 A random...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a minimum and maximum real number, then generates and prints a random number in the requested range. The script should then do the same for an integer range. Sample output: Enter a minimum real value: 0.5 Enter a maximum real value: 30 A random number in the range ( 0.5000, 30.0000 ) is 1.7851 Enter a minimum integer value: -10 Enter a maximum integer...
Three workers at a fast food restaurant pack the take-out chicken dinners. John packs 45% of...
Three workers at a fast food restaurant pack the take-out chicken dinners. John packs 45% of the dinners but fails to include a salt packet 4% of the time. Mary packs 25% of the dinners but omits the salt 2% of the time. Sue packs 30% of the dinners but fails to include the salt 3% of the time. You have purchased a dinner and there is no salt.           a. Find the probability that John packed your dinner.          ...
OK Corporation sells gift cards in various denominations. The company likes to sell these cards because...
OK Corporation sells gift cards in various denominations. The company likes to sell these cards because cash is collected immediately, but a certain percentage will never be redeemed for merchandise. On December 1, Year One, OK reported a balance in unearned revenue of $728,000 from the sale of gift cards. a. During December, OK sold an additional $578,000 in gift cards. Prepare this journal entry. b. During December, gift cards totaling $327,000 were redeemed to purchase inventory that had originally...
script for Secant Method. Using Matlab or Octave. The data: y = x.^2 - 1.2 x_lower...
script for Secant Method. Using Matlab or Octave. The data: y = x.^2 - 1.2 x_lower = 0.4 x_upper = 0.6 Es = 0.5*10^(2-n) n = 5
Bash Script Write a script using while-do-done loop to convert the kilometers to miles. - Ask...
Bash Script Write a script using while-do-done loop to convert the kilometers to miles. - Ask the user to input the number of kilometers they need to travel. - Display the number of equivalent miles for the number. Use formula, Kilometers = miles/0.62137 - Every time the loop runs, it should ask the user if they want to continue, if user enters “Y” or “y”, then the loop runs again, if user enters “N” or “n”, then stop the loop...
Question 1 Steel Restaurant Supply sells various equipment and supplies to restaurants in the local and...
Question 1 Steel Restaurant Supply sells various equipment and supplies to restaurants in the local and surrounding communities. The company’s executive, Mr. Daniel, has requested your help in preparing a cash budget for the month of May and June. Mr. Daniel accumulated the following information for you. 1. The cash balance at May 1 was estimated to be RM120,000. 2. Actual sales of April and budgeted sales for May and June are as follows: April May June Actual Budgeted RM...
Jana Restaurant Supply sells various equipment and supplies to restaurants in the local and surrounding communities....
Jana Restaurant Supply sells various equipment and supplies to restaurants in the local and surrounding communities. The company’s executive, Mr. Hasan, has requested your help in preparing a cash budget for the month of June. Mr. Hassan accumulated the following information for you. 1. The cash balance at May 1 was estimated to be RM20,000. 2. Actual sales of April and May and budgeted sales for June are as follows: April (RM) May (RM) June (RM) Cash sales 33,000 31,000...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT