On the top left i have the number i am currently writing for example “271”, when i hit enter the number is supposed to go down to the 10 next numbers in the left row where the last 10 numbers ive written are. And on the bottom left is the average.

On the top right i have my mouse’s cursor position, when i click left mouse the number will go down to the next 10 numbers in the right row and the last number is the average.

This is the code I have as of right now, however I cant get the enter function to work. please help:

int numbers[] = new int [10];
int currentNumberIndex = 0;
int mouseClicks[] = new int[10];
int currentClickIndex = 0;
String currentNumberString = "";
int aaa = currentNumberString.length();
void setup() {
size(300,300);
background(0);
fill(255,105,180);
textSize(25);
textAlign(LEFT, TOP);
}
void draw() {
clear();
if(currentNumberString != "") {
printNumbers(Integer.parseInt(currentNumberString), mouseY, 0);
}
else {
printNumbers(0, mouseY, 0);
}
for(int i = 0; i < numbers.length; i++) {
text(Integer.toString(numbers[i]) + "" + Integer.toString(mouseClicks[i]),0,1 + 30 +30);
}
}
void mouseReleased() {
mouseClicks[currentClickIndex] = mouseY;
currentClickIndex = currentClickIndex == 9 ? 0 : currentClickIndex + 1;
}
void keyPressed() {
if(Character.isDigit(key) && aaa <= 5) {
currentNumberString += key;
}
else if (keyCode == 10 && currentNumberString != "") {
numbers[currentNumberIndex] = Integer.parseInt(currentNumberString);
currentNumberIndex = currentNumberIndex == 9 ? 0 : currentNumberIndex + 1;
currentNumberString = "";
}
}
void printNumbers(int number1, int number2, int row) {
textAlign(LEFT, TOP);
text(Integer.toString(number1), 0, row * 30);
textAlign(RIGHT, TOP);
text(Integer.toString(number2), 300, row * 30);
}
int calculateAverage(int[] numbers) {
int sum = 0;
for(int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum / numbers.length;
}

So removing clear brought us a step forward: we now know that clear deletes our output (that we want to be permanent) AND that it stacks on top (instead of being underneath each other line by line)

The x-value must be 150 (because of textAlign(RIGHT, TOP); in printNumbers() - when I use this textAlign, I usually make another textAlign(LEFT); to go back to default after text(); I haven’t done this here). You could also say textAlign(LEFT); before the for-loop.

and I inserted i*30 at y-value of text() so we got a line-feed

int numbers[] = new int [10];
int currentNumberIndex = 0;
int mouseClicks[] = new int[10];
int currentClickIndex = 0;
String currentNumberString = "";
int aaa = currentNumberString.length();
void setup() {
size(700, 500);
background(0);
fill(255, 105, 180);
textSize(25);
textAlign(LEFT, TOP);
}
void draw() {
clear();
//translate(55, 50);
if (currentNumberString != "") {
printNumbers(Integer.parseInt(currentNumberString), mouseY, 0);
} else {
printNumbers(0, mouseY, 0);
}
for (int i = 0; i < numbers.length; i++) {
text(Integer.toString(numbers[i]) + "" + Integer.toString(mouseClicks[i]),
150, 1 + 30 +30 + i * 30); // x-value 150 and I inserted i*30 at y-value !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
}
void mouseReleased() {
mouseClicks[currentClickIndex] = mouseY;
currentClickIndex = currentClickIndex == 9 ? 0 : currentClickIndex + 1;
}
void keyPressed() {
if (Character.isDigit(key) && aaa <= 5) {
currentNumberString += key;
} else if (keyCode == 10 && currentNumberString != "") {
numbers[currentNumberIndex] = Integer.parseInt(currentNumberString);
currentNumberIndex = currentNumberIndex == 9 ? 0 : currentNumberIndex + 1;
currentNumberString = "";
}
}
void printNumbers(int number1, int number2, int row) {
textAlign(LEFT, TOP);
text(Integer.toString(number1), 0, row * 30);
textAlign(RIGHT, TOP);
text(Integer.toString(number2), 300, row * 30);
}
int calculateAverage(int[] numbers) {
int sum = 0;
for (int i = 0; i < numbers.length; i++) {
sum += numbers[i];
}
return sum / numbers.length;
}
//