REALLY basic functions problem

Oh yeah I’ve less of a problem just running it within the setup.

But this is the brief,

"• Write a program which has a global array of 50

integers with random values assigned to the array.

• The values should be displayed in the console window in a row

• Write a function ‘getArrayMin’ to return the minimum value in the array.

• Draw a circle in the centre of the window with the
greyscale colour returned by the getArrayMin function.

The circle should be 50% the size of the window

• The value returned should be displayed inside the
circle and be at least 50% the size of the circle

• The value should be visible whether the circle is black or white"

So I have to do it in a function. For example, this works and I think it’s what you’re describing…

int a[]= new int [50];
int MIN= 255;

void setup()
{
size(450,450);

for(int i=0; i < a.length; i++)
{
a[i] = (int) random (60,255);
print(a[i]+" , ");
println(“MIN+”,MIN);
if(a[i]< MIN){
MIN= a[i];

  }
  }
 }

void draw(){
fill (MIN);
textSize(width/4);
ellipse(width/2,height/2,width/2,height/2);

fill (240);
textSize(width/4);
text(MIN, width*.32 ,height*.58);

}

When I try to use “int” as the return type and say “return (MIN);” it says “This method must return a result of type int”

I really have no idea how to use these things.

2 Likes