Need help with repeating switch cases
in
Programming Questions
•
1 year ago
Hello,
I am very new new in programming processing. Thanks for being here!
I am trying to write a code to check the right position of numbers in a row. That means, if number 1 is at position 1, everything is allright and the errorscore is 0. Is number 1 at position 2 the errorscore is 1. I want to check the positions for 80 numbers and don't know how to write that using inkrements.
For me it's tricky cause when number 12 is on position 9 for example then I would have to work with negative numbers.
I hope you can help me!
Thx!
There is my code so far:
int[] nr;
int i;
int pos1 = '1'; //Zahl wird ausgelesen
int pos2 = '2'; //Zahl wird ausgelesen
int pos3 = '3'; //Zahl wird ausgelesen
float errorscore1;
//for (i=0; i<86; i++)
// println (i);
switch (pos1)
{
case '1':
errorscore1 = 0;
println (errorscore1);
break;
case '2':
errorscore1 = 1;
println (errorscore1);
break;
case '3':
errorscore1 = 2;
println (errorscore1);
break;
}
I am very new new in programming processing. Thanks for being here!
I am trying to write a code to check the right position of numbers in a row. That means, if number 1 is at position 1, everything is allright and the errorscore is 0. Is number 1 at position 2 the errorscore is 1. I want to check the positions for 80 numbers and don't know how to write that using inkrements.
For me it's tricky cause when number 12 is on position 9 for example then I would have to work with negative numbers.
I hope you can help me!
Thx!
There is my code so far:
int[] nr;
int i;
int pos1 = '1'; //Zahl wird ausgelesen
int pos2 = '2'; //Zahl wird ausgelesen
int pos3 = '3'; //Zahl wird ausgelesen
float errorscore1;
//for (i=0; i<86; i++)
// println (i);
switch (pos1)
{
case '1':
errorscore1 = 0;
println (errorscore1);
break;
case '2':
errorscore1 = 1;
println (errorscore1);
break;
case '3':
errorscore1 = 2;
println (errorscore1);
break;
}
1