Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How can I do this program ?

1 visualizzazione (ultimi 30 giorni)
Hashem Alsayid
Hashem Alsayid il 12 Ott 2015
Chiuso: MATLAB Answer Bot il 20 Ago 2021
  2 Commenti
Geoff Hayes
Geoff Hayes il 12 Ott 2015
Hashem - what have you tried so far? Please show your work and explain any difficulties you are experiencing with your code.
Hashem Alsayid
Hashem Alsayid il 13 Ott 2015
I did this so far, however I did not know how to do the switch statement and a while loop to keep asking the customer if they are done with the order.

Risposte (1)

Image Analyst
Image Analyst il 12 Ott 2015
Here's a snippet that may help. It lets you ask the user for numbers:
% Ask user for two floating point numbers.
defaultValue = {'45.67', '78.91'};
titleBar = 'Enter a value';
userPrompt = {'Enter floating point number 1 : ', 'Enter floating point number 2: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
usersValue2 = str2double(caUserInput{2})
% Check for a valid number.
if isnan(usersValue1)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into usersValue1.
usersValue1 = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nI will use %.2f and continue.', usersValue1);
uiwait(warndlg(message));
end
Also check out the fprintf() function so that you can print up the list for the user.
  2 Commenti
Hashem Alsayid
Hashem Alsayid il 13 Ott 2015
I want it with switch statement and a while loop
Image Analyst
Image Analyst il 13 Ott 2015
OK. So do that. The help has examples for those. Did you try to try them or adapt them??? How else is your homework going to get done? We can't just do the whole thing for you.

Community Treasure Hunt

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

Start Hunting!

Translated by