% calculates the population of a city from year 2000 to 2020
var popstart : int := 80000
var popgrowth : real
var popend : real
var growthrate : real := 0.03
% popgrowth := popstart * growthrate
for i : 2000..2020 by 1
popgrowth := popstart * growthrate
end for
put "year population"
put "==== =========="
put i, " ", popgrowth
当我运行程序时,我得到错误变量“我还没有被声明”当我将 i 声明为变量时,我得到错误“我已经被声明”
输出应如下所示:
年人口
==== ==========
2000 xxxxxxxxxx ~ 2020 XXXXXXXXXX
这是一个类似但更简单的程序,我成功地完成了我在上面的程序中尝试做的事情。
for i : 4 .. 19 by 3
put i
end for
请帮忙!并提前感谢!