write a Matlab script that asks a group of up to 40 members to enter their height (in cm) and their weight (in kg).
조회 수: 1 (최근 30일)
이전 댓글 표시
It should work like this: Prompt the user to enter the two values. • Read in the input from the user, if any of the input values is ≤ 0, the program stops asking for more data. Otherwise, it stores the input value in an appropriate variable. • Repeat steps for the next member, until the 40th member is done. • It finishes by printing a message indicating the number of members entered.
My script which doesn't quite work is:
While continue==1
Height= input('Enter your height in cm: ')
Weight= input('Enter your weight in kg: ')
If height<0
Continue=0;
End
If weight<0
Continue=0;
End
End
댓글 수: 0
답변 (1개)
Star Strider
2015년 12월 11일
Please consult the documentation on Case and Space Sensitivity, and the relevant documentation for the functions you are using.
For example, While is not the same as while.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!