if.else函数嵌套时出现了一些问题。这是代码的预览。
If total>10 then
writeln('You are a great student who loves to study!');
else;
if (total>8) and (total<=10) then
writeln ('You are a good student,just take more practice.');
else;
if (total>6) and (total<=8) then
writeln ('You are an average student. Try harder in all aspects of your study.');
else;
writeln ('You are an under-average student. Try even harder!');
readkey;
readln;
End.
我试着修改代码,但似乎不起作用。你能帮我做这件事吗?
将else;
的所有实例替换为else
,并删除每个else
之前的分号。
if total > 10 then
WriteLn('You are a great student who loves to study!')
else if (total > 8) and (total <= 10) then
WriteLn ('You are a good student; it just takes more practice.')
else if (total > 6) and (total <= 8) then
WriteLn ('You are an average student. Try harder in all aspects of your study.')
else
WriteLn ('You are a below-average student. Try even harder!');
ReadKey;
ReadLn;