作业帮 > 综合 > 作业

英语翻译在大学拿了一门processing的课,作业要求如下:1.Create an array that holds

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/14 15:56:04
英语翻译
在大学拿了一门processing的课,作业要求如下:
1.Create an array that holds 10 ints.
2.Declare a float variable.This will hold the average of the array of ints.
2.Define a function that does not return anything,but populates the array with 10 random values between 0 and 100 (inclusive...be careful that 100 has the same chance as any other number to be saved to the array).Make this function also print the array and save its (correct) average to the variable declared in step 2 of this assignment.
3.Have the above function get called in setup() as well as any time the 'r' key is pressed (but not any other key).Use the keyPressed() event for this.
4.Have the average (held in the variable from step 2) print to the console when the 'a' key is pressed (but not any other key).Use the keyPressed() event for this,too.
4.Define a function that returns (but does not print or otherwise display) a random element of this array.Using the previously mentioned function,use println() within a mousePressed() event definition to have a random element (returned from the function you define in this step) print to the console on every mouse click.
1,创建一个int类型的数组,长度为10
2,定义一个float类型变量,这个变量将用来保存1中int数组10个数的平均值
3,定义一个返回空类型的方法(也就是void),用1到100之间的随机数初始化第1步中的数组,并让这个方法也能打印这个数组,并且将数组的平均值保存到第2步中的变量中
4,定义两个方法setup()和keyPressed(),在setup()中当字母'r'(而不是其他的任何一个字母)被按下时(也就是当且仅当r被按下时),第3步中定义的方法会被调用,而使用keyPressed()来实现按键的功能
5,定义一个方法,这个方法不会打印或者有任何其他的显示,它将返回一个1中数组的一个随机元素.使用前面提到的方法,用println()和一个mousePressed()事件来获得这个随机元素,当你每一次按下鼠标时都会将之打印到控制台
有不懂的可以继续问我