1
我现在正在参加计算机科学课,但我不知道如何将由3分制成的平均值转换为字母等级。起初,我以为我可以这样做:将平均数转换成等级时的类型不匹配(初学者)
PRINT name$(c); TAB(6) ; USING("###.#", average(c))
由于:
PRINT name$(c); TAB(6) ; USING("***something for text here***", average(c))
但我的搜索和淘互联网上后,我想出了什么。过了一段时间我重写了我的大部分代码,但它仍然无法正常工作。有人能告诉我,我能做些什么才能使它工作?
这就是:
dim names(20)
dim average$(20)
x = 0
input "Please input Teacher's name:"; teacher$
rem teacher$
cls
input "Input student's name:"; studentname$
do while studentname$ <> ""
name$(x)=studentname$
rem name$(x)
input "Input first number:"; e
input "Input second number:"; f
input "Input third number:"; g
avg$=(e+f+g)/3
average(x)= avg
x=x+1
cls
input "Input the next name or press enter to finish:"; studentname$
loop
print teacher$; "'s Class Report"
for c = 1 to X
if (avg$>89 and avg$<101) then let avg= "A" else if
if (avg$>79 and avg$<89) then let avg= "B" else if
if (avg$>69 and avg$<79) then let avg= "C" else if
if (avg$>59 and avg$<69) then let avg= "D" else if
if (avg$<59) then let avg= "F"; print names(c), TAB(6) average$(c)
next c
end
您计算基于'avg'然后输出'$平均的信(C)'。做相反的事情。 – GSerg
而且很容易混淆,所以最好让你的变量名称不同。你可能在'avg'和'average'之间混淆了。也许可以将它重构为'class_averages',以便更容易记住。 –