help me do while function
显示 更早的评论
Prompt the user to enter a value for height in inches (59-78) and weight in pounds (90-350). I don't know what I can't do that. I enter the height is 50, but it doesn't require me input again. it just show enter the weight.
inches = input('Enter the height in inches (59-78): ');
while (inches <59 && inches>78)
disp('Enter the height in inches (59-78): ');
end
pounds = input('Enter the weight in pounds (90-350): ');
while (pounds <90 && pounds > 350)
pounds = input('Enter the weight in pounds (90-350): ');
end
采纳的回答
更多回答(3 个)
THANH NGUYEN
2013-2-26
0 个投票
1 个评论
Sean de Wolski
2013-2-26
Use strcmp
doc strcmp
Yopu may also need the ~ operator or not
doc not
E.g:
~strcmp('Sean','F')
THANH NGUYEN
2013-2-26
编辑:Walter Roberson
2013-2-26
1 个评论
Walter Roberson
2013-2-26
If the gender is 'F' then it is not 'M' so the "gender ~= 'M'" part would be true. No matter what you enter, one of the tests is going to be true, and you have used "or" between the parts. Perhaps you should not have used "or".
You should also have used strcmp() like Sean wrote.
THANH NGUYEN
2013-2-26
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!