MATLAB switch输出百分制成绩

MATLAB switch输出百分制成绩

输入一个百分制成绩,要求输出成绩等级,A,B,C,D,E.其中90-100分为A,80-89为B,70-79为C,60-69分为D,60分以下为E.

performance=input('请输入百分制成绩');

switch x(performance/10)

case{0,1,2,3,4,5}

disp(E);

case{6}

disp(D);

case{7}

disp(C);

case{8}

disp(D);

case{9}

disp(A);

otherwise

disp(wrong);

end

这样为什么不对

问答/179℃/2025-04-06 10:33:55

优质解答:

原代码的主要问题是disp() 里面的A、B等都是字符,需要加' ',

另外就是switch x(performance/10) 里的x不知道是什么.新写的命令如下:

————————————————————————————————————————

performance=input('请输入百分制成绩:');

if (performance>100) | (performance

我来回答

猜你喜欢

Copyright © 作文乐园 Inc.
Www.821218.Com All Rights Reserved
网站、品牌合作请联系