I need values that go like this:
0.5 1 1.5 2 2.5 3 Etc
I made a function but I don't know if it can be done in another way that requires less code, here is my code:
private String GetNumber(int spinner) {
String result = "0";
if (spinner == 1) {
result = "0.5";
}
if (spinner == 2) {
result = "1";
}
if (spinner == 3) {
result = "1.5";
}
if (spinner == 4) {
result = "2";
}
if (spinner == 5) {
result = "2.5";
}
if (spinner == 6) {
result = "3";
}
if (spinner == 7) {
result = "3.5";
}
if (spinner == 8) {
result = "4";
}
if (spinner == 9) {
result = "4.5";
}
if (spinner == 10) {
result = "5";
}
if (spinner == 11) {
result = "5.5";
}
if (spinner == 12) {
result = "6";
}
if (spinner == 13) {
result = "6.5";
}
if (spinner == 14) {
result = "7";
}
if (spinner == 15) {
result = "7.5";
}
if (spinner == 16) {
result = "8";
}
if (spinner == 17) {
result = "8.5";
}
if (spinner == 18) {
result = "9";
}
if (spinner == 19) {
result = "9.5";
}
if (spinner == 20) {
result = "10";
}
return result;
}
Is it the correct way or is there an easier way?