Question

In: Computer Science

fix all errors in code below: PLEASE DO ASAP, THIS IS IN MATLAB %Welcome Message fprintf('****Welcome...

fix all errors in code below: PLEASE DO ASAP, THIS IS IN MATLAB

%Welcome Message

fprintf('****Welcome to Comida Mexicana De Mentiras****\n');

flag =0;

while flag ==1

% Asking the user for the order

choice = input('Please enter your order \n 1. Burrito Bowl \n 2.Burrito \n 3. Tacos \n Enter 1 or 2 or 3: ','s'); switch choice

case choice==1

% For Burrito Bowl

BaseCost = 4;

[Protein, PC] = proteinChoice();

[FinalAmount,~]= AmountCalculator(BaseCost,PC); displayMessage("Burrito Bowl",Protein,FinalAmount);

case choice==2

end

end

% For Burrito

BaseCost = 5;

[Protein, PC] = proteinChoice(); [FinalAmount,~] = AmountCalculator(BaseCost,PC); displayMessage("Burrito",Protein,FinalAmount);

for proteinChoice == 3 % For Tacos

BaseCost = 3;

[Protein, PC] = proteinChoice(); [FinalAmount,~] = AmountCalculator(BaseCost,PC); displayMessage("Tacos",Protein,FinalAmount);

else

%If the user enters a choice which is not 1, 2 or 3

fprintf('Please enter a valid choice \n');

% Giving the user an option to re-enter their order

flag = input('Would you like to re-enter your order? Enter 1 for yes and 0 for no:\n');

end

% This zero input, two output function is used to get the user's protein

% choice

function [Protein,PC] = proteinChoice()

Protein_Option = input('Enter your choice of Protein: \n 1. Chicken \n 2. Steak \n 3. Carnitas \n 4. Sofritas \n 5. Veggie \n');

% PC refers to Protein cost, which is the cost of the protein add on switch Protein_Option

case 1

PC = 2;

Protein

case 2

PC = 2;

Protein

case 3

PC = 2;

Protein

case 4

PC = 1;

Protein

case 5

= "Chicken"; = "Steak";

= "Carnitas"; = "Sofritas";

PC = 0;

Protein = "Veggie";

% The following two input, one output function is used to calculate the

% total cost including tax for the order.

function FinalAmt = AmountCalculator(BC,PC)

% CostAdder and TaxCalc are anonymous functions

% The calculations in the following anonymous functions are correct, but

% the syntax is not.

@CostAdder = (x) sum(x);

@TaxCalc = (x) 0.075*x; % Assuming a 7.5% tax rate

TotalCost = CostAdder([BC,PC]);

Tax = TaxCalc(TotalCost);

FinalAmt = CostAdder([TotalCost, Tax]);

end

% This three input, zero output function is used to display the total cost

% to the user.

function displayMessage(BaseOrder,Protein,FA)

disp(' Your %f %f cost $%.2f\n',Protein,BaseOrder,FA); end

Solutions

Expert Solution

clc;%Welcome Message

fprintf('****Welcome to Comida Mexicana De Mentiras****\n');

flag = 1;

while flag ==1

% Asking the user for the order

choice = input('Please enter your order \n 1. Burrito Bowl \n 2.Burrito \n 3. Tacos \n Enter 1 or 2 or 3: ','s');

switch choice

case '1'

% For Burrito Bowl

BaseCost = 4;

[Protein, PC] = proteinChoice();

FinalAmount= AmountCalculator(BaseCost,PC); displayMessage("Burrito Bowl",Protein,FinalAmount);

case '2'

% end

% For Burrito

BaseCost = 5;

[Protein, PC] = proteinChoice(); FinalAmount = AmountCalculator(BaseCost,PC);

displayMessage("Burrito",Protein,FinalAmount);

case '3' % For Tacos

BaseCost = 3;

[Protein, PC] = proteinChoice(); FinalAmount = AmountCalculator(BaseCost,PC); displayMessage("Tacos",Protein,FinalAmount);

otherwise

%If the user enters a choice which is not 1, 2 or 3

fprintf('Please enter a valid choice \n');

end

% Giving the user an option to re-enter their order

flag = input('Would you like to re-enter your order? Enter 1 for yes and 0 for no:\n');

end

% This zero input, two output function is used to get the user's protein

% choice

function [Protein,PC] = proteinChoice()

Protein_Option = input('Enter your choice of Protein: \n 1. Chicken \n 2. Steak \n 3. Carnitas \n 4. Sofritas \n 5. Veggie \n');

switch Protein_Option

% PC refers to Protein cost, which is the cost of the protein add on switch Protein_Option

case 1

PC = 2;

Protein = 'Chicken';

case 2

PC = 2;

Protein = 'Steak';

case 3

PC = 2;

Protein = 'Carnitas';

case 4

PC = 1;

Protein = 'Sofritas';

case 5

PC = 0;

Protein = "Veggie";

end

end

% The following two input, one output function is used to calculate the

% total cost including tax for the order.

function FinalAmt = AmountCalculator(BC,PC)

% CostAdder and TaxCalc are anonymous functions

% The calculations in the following anonymous functions are correct, but

% the syntax is not.

CostAdder = @(x) sum(x);

TaxCalc = @(x) 0.075*x; % Assuming a 7.5% tax rate

TotalCost = CostAdder([BC,PC]);

Tax = TaxCalc(TotalCost);

FinalAmt = CostAdder([TotalCost, Tax]);

end

% This three input, zero output function is used to display the total cost

% to the user.

function displayMessage(BaseOrder,Protein,FA)

fprintf(' Your %s %s cost $%.2f\n',BaseOrder,Protein,FA); end

%output

----------------------------------------------------------------------------------------------------
Your ThumbsUp on this answer matters to me a lot :)
----------------------------------------------------------------------------------------------------
For any further clarifications, reach out in the comments section


Related Solutions

Please fix all of the errors in this Python Code. import math """ A collection of...
Please fix all of the errors in this Python Code. import math """ A collection of methods for dealing with triangles specified by the length of three sides (a, b, c) If the sides cannot form a triangle,then return None for the value """ ## @TODO - add the errlog method and use wolf fencing to identify the errors in this code def validate_triangle(sides): """ This method should return True if and only if the sides form a valid triangle...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and...
(CODE IN PYTHON) Program Input: Your program will display a welcome message to the user and a menu of options for the user to choose from. Welcome to the Email Analyzer program. Please choose from the following options: Upload text data Find by Receiver Download statistics Exit the program Program Options Option 1: Upload Text Data If the user chooses this option, the program will Prompt the user for the file that contains the data. Read in the records in...
Need to fix this code for tc -tac-toe game .. see the code below and fix...
Need to fix this code for tc -tac-toe game .. see the code below and fix it #include <iostream> using namespace std; void display_board(); void player_turn(); bool gameover (); char turn ; bool draw = false; char board [3][3] = { {'1', '2', '3'}, { '4', '5', '6'}, { '7', '8', '9'}}; int main() { cout << " Lets play Tc- Tac- toe game " <<endl ; cout << " Player 1 [X] ----- player 2 [0] " <<endl <<endl;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner; public class Booolean0p {        public class BooleanOp {            public static void main(String[] args) {                int a = 0, b = 0 , c = 0;                Scanner kbd = new Scanner(System.in);                System.out.print("Input the first number: ");                a = kbd.nextInt();                System.out.print("Input...
Please fix all the errors in this Python program. import math def solve(a, b, c): """...
Please fix all the errors in this Python program. import math def solve(a, b, c): """ Calculate solution to quadratic equation and return @param coefficients a,b,class @return either 2 roots, 1 root, or None """ #@TODO - Fix this code to handle special cases d = b ** 2 - 4 * a * c disc = math.sqrt(d) root1 = (-b + disc) / (2 * a) root2 = (-b - disc) / (2 * a) return root1, root2 if...
I'm getting an error message with this code and I don't know how to fix it...
I'm getting an error message with this code and I don't know how to fix it The ones highlighted give me error message both having to deal Scanner input string being converted to an int. I tried changing the input variable to inputText because the user will input a number and not a character or any words. So what can I do to deal with this import java.util.Scanner; public class Project4 { /** * @param args the command line arguments...
Using python, produce code that mimics some ATM transactions: a. A welcome message must be displayed...
Using python, produce code that mimics some ATM transactions: a. A welcome message must be displayed initially reflecting the appropriate time of day (for example: Good Night, Welcome to Sussex Bank). b. Assume the user’s account balance is $5375.27. c. Allow the user to enter a pin number that does not have to be validated: def atm_login(): pin_number = input("Please enter your (4 digit) pin number: ") # display welcome message welcome_message() d. The message should be followed by a...
in c++ please follow instructions and fix the errors and please make a comment next to...
in c++ please follow instructions and fix the errors and please make a comment next to each code error you fix. Below are 25 code fragments, inserted into a try catch block. Each line has zero or more errors. Your task is to find and remove all errors in each fragment. Do not fix problems by simply deleting a statement; repair the problems by changing, adding, or deleting a few characters. There may be different ways to fix them You...
Fill in the blanks in the MATLAB code below.
Fill in the blanks in the MATLAB code below. (Do not type unnecessary words or blank spaces in your response. The correct answers are case-sensitive.) % Consider a row vector v. % Complete the lines of code below to find the average and standard deviation of the elements of vector v such that these two values are assigned to variables M and S, respectively. E = G =
Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public...
Can you fix the errors in this code? import java.util.Scanner; public class Errors6 {    public static void main(String[] args) {        System.out.println("This program will ask the user for three sets of two numbers and will calculate the average of each set.");        Scanner input = new Scanner(System.in);        int n1, n2;        System.out.print("Please enter the first number: ");        n1 = input.nextInt();        System.out.print("Please enter the second number: ");        n2 =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT