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

답변 (2개)

Image Analyst
Image Analyst 2023년 1월 7일

0 개 추천

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

Ali
Ali 2023년 1월 7일
편집: Ali 2023년 1월 7일
I am sorry for my mistake. I edited
Yes, but you didn't attach the files.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2023년 1월 7일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

Ali
2023년 1월 7일

댓글:

2023년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by