Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How to run this code?
1 回表示 (過去 30 日間)
古いコメントを表示
A=input('What would you like to do?: ','s');
if strcmp(A,'add book')
Tit= input('Ask for title: ','s');
Aut=input('Ask for author: ','s');
No_pg=input('Ask for number of pages: ','s');
fprintf('Title: %s \n',Tit)
fprintf('Author: %s \n',Aut)
fprintf('Number of pages: %s \n',No_pg)
elseif strcmp(A,'quit')
disp('Good bye')
else
disp('Nothing entered')
end
2 件のコメント
Jan
2017 年 4 月 25 日
The question is not clear. Most likely you can either run this in the command window or write it to a script or function M-file to start it from there. Please explain which problem you have with running this code.
回答 (1 件)
KSSV
2017 年 4 月 25 日
A=input('What would you like to do?: ','s');
if strcmp(A,'add book')
Tit= input('Ask for title: ','s');
Aut=input('Ask for author: ','s');
No_pg=input('Ask for number of pages: ','s');
fprintf('Title: %s \n',Tit)
fprintf('Author: %s \n',Aut)
fprintf('Number of pages: %s \n',No_pg)
elseif strcmp(A,'hi')
disp('Good bye')
else
disp('Nothing entered')
end
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!