html - GML 存储用户输入

标签 html input storage gml

所以我一直在开发一个程序,要求用户输入一个值,当用户通过输入 -99 退出代码时,它应该返回所有数字的总值和平均值,但我很难过我的值不断被前一个值覆盖...这是我的代码

{
var user_Input;<br>
var output_msg;<br>
var count;<br>
var highest;<br>
var value;<br>
var total;<br>

count = 0;
do
   {
   user_Input = get_integer("Enter a number To add To the List(Enter -99 to    leave)",-99);
     if (user_Input == (-99)){
         continue}
         count += 1;
         value = 0;
         value = value + user_Input;
         average = value/count;
      }

     until(user_Input == (-99)){
     count -=1;
     user_Input = user_Input + 99;
     output_msg=("#Numbers Entered: " + string(count) + "##Total value of numbers: " +                       string(highest) + "## Average:" + string(average));`
     }
     show_message(output_msg);
     }

我如何制作它才不会覆盖前一个?

最佳答案

这是因为每次执行 while 循环时都将 value 设置为 0。尝试设置

value = 0;

在开始 do until 循环之前。也许就在

count = 0;

像这样:

count = 0;
value = 0;
do{
   user_Input = get_integer("Enter a number To add To the List(Enter -99 to leave)",-99);
   if (user_Input == (-99)){continue}
   count += 1;
   value = value + user_Input;
   average = value/count;
  }

关于html - GML 存储用户输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26769906/

相关文章:

html - 与 CSS 相比,使用 ImageMagick 调整图像大小有什么好处?

ios - 为什么NSFileSystemFreeSize中的值与iOS设置中报告的可用大小不同?

html - 为什么我的代码找不到来自 mail.com 的登录表单字段?

html - 角度输入文件 : Selecting the same file

php - 每周将 XML 文件保存到数据库

mongodb - 存储数百万个日志文件 - 每年大约 25 TB

javascript - 我在测试付款中收到错误消息 "Class ' Stripe' not found”

javascript - 在前台同步拖放文件上传而不使用 AJAX?

javascript - 使用 2 个 div 向下滚动固定 div

python - 如何读取键盘输入?