필터 지우기
필터 지우기

Why is my code not working?

조회 수: 1 (최근 30일)
Eduardo Gallegos
Eduardo Gallegos 2022년 12월 13일
답변: Voss 2022년 12월 13일
How can I get it to display the message if the x meets the requirements?
Code
input('Enter a test grade between 0 and 100: ')
if (x >= 90)
disp('The student earned an A.')
elseif (x >= 65)
disp(The student passed the test_11)
else
disp('The student did not pass the test.')
end
I get this error
Invalid expression. Check for missing multiplication operator, missing or unbalanced
delimiters, or other syntax error. To construct matrices, use brackets instead of
parentheses.

채택된 답변

Voss
Voss 2022년 12월 13일
The cause of the error is that the second disp line doesn't have quotes:
disp(The student passed the test_11)
It should be:
disp('The student passed the test_11')
But to get the program to work, you'll want to assign the output from input to the variable x:
x = input('Enter a test grade between 0 and 100: ');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Other Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by