Newbie with seemingly simple problem
in
Programming Questions
•
10 months ago
Hi,
I Can't seem to figure out why I'm getting a " This method must return a result of type int" error pointing to the determineLT() method.
Code:
int qty;
int lt;
void setup() {
qty = setQty(7.0);
println(qty);
}
int setQty(float s) {
if (360 % s != 0) {
lt = determineLT(s);
return floor (360/s);
}
else {
lt = 360;
return int (360/s);
}
}
int determineLT(float incr) {
for (int i = 360; i > 0; i--) {
float j = float(i);
if (j % incr == 0) {
println(i);
return i;
}
else {
return 1;
}
}
}
As far as I can tell—it is returning an int. Any help on this would be greatly appreciated.
Thanks!
I Can't seem to figure out why I'm getting a " This method must return a result of type int" error pointing to the determineLT() method.
Code:
int qty;
int lt;
void setup() {
qty = setQty(7.0);
println(qty);
}
int setQty(float s) {
if (360 % s != 0) {
lt = determineLT(s);
return floor (360/s);
}
else {
lt = 360;
return int (360/s);
}
}
int determineLT(float incr) {
for (int i = 360; i > 0; i--) {
float j = float(i);
if (j % incr == 0) {
println(i);
return i;
}
else {
return 1;
}
}
}
As far as I can tell—it is returning an int. Any help on this would be greatly appreciated.
Thanks!
1