How can I write a program for admin option.

disp("Welcome to our coffee machine, how can I help you")
choice = input(" 1) Esspreso\n 2) Cappocino\n 3) Makiato\n ");
coffee = [1 3; 2 4; 3 5];
money = 0;
change = 0;
price = 0;
switch choice
case 1
disp("Good choice, our espresso is the best in town, that is 3 KM ")
price = coffee(1,2);
money = input("please enter the money -> ");
while(price>money && money>0)
disp("Perfect, we need ")
disp(price-money)
disp("KM more")
money = money + input("Your money -> ");
end
if(money>price)
disp("Ok you have")
disp(money - price)
disp("KM of change, there you go, and your coffee is being prepared")
end
if(money == price)
disp("your coffee is being prepared")
end
disp(".")
disp("..")
disp("......")
pause(1)
disp("Enjoy your cofffee")
otherwise
disp('Wrong coffee number !')
end
I did it just for Espresso. I am interested about that how can I add admin option which will calculate amount of Espresso sold

Answers (2)

You must have another function, either in the same m-file or a separate one, called "admin" and that program or function opens up a window called "results". What else can we say? I mean, it does what you tell it to, and we don't know exactly what that is because you didn't show us the relevant code.
Looks like you chose not to read the community guidelines for some reason and just posted an almost unanswerable question. Here is another chance to fix your post:
If you have any more questions, then attach your .m and .fig files for your main program and for the "admin" program with the paperclip icon after you read this:

2 Comments

Ali
Ali on 7 Jan 2023
Edited: Ali on 7 Jan 2023
I am sorry for my mistake. I edited
Yes, but you didn't attach the files.

Sign in to comment.

See questdlg . You would need to slightly alter your switch cases and add one to cover admin .
You would also need to alter your existing code to count the sales.
You should consider creating a function to handle the sale of any particular type of coffee. You would pass in the type of coffee, and the price, and a data structure representing statistics. It would return an updated structure representing statistics.

Asked:

Ali
on 7 Jan 2023

Commented:

on 7 Jan 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!