Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am trying to make a program where I can't find a solution for this:
I want to check if position_x is 0 or 20 or 40 or 60 or 80 or 100 or 120... until 1280 (always plus 20).
I hope you can help me further,
Thanks!
You can try using the modulus here, e.g.
if (position_x % 20 == 0 && position_x >=0 && position_x <= 1280) {
System.out.println("position_x is a multiple of 20 and within range.");
}
else {
System.out.println("position_x is out of range or not a multiple of 20.");
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have part of the code:
public void CollectorOrPocrushka(double output) {
if (output <= 0.4999999999999999999999)
System.out.println("покришка");
if (output > 0.5 && output <= 1.0)
System.out.println("колектор");
}
Can I write float number 0.4999999999999999999999 shorter?
Something like that:
0.49F
0.49e^10
If your question is about to simplify the first if condition and your goal is to check if the output is less than or equal 0.4999999999999999999999, you can easily write
if(output < 0.5)
System.out.println("покришка");
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
The Question is
if c=12;
c=c++ + ++c;
what will be the working solution for this?
like how would it be ex(12+13)something like this
please specify what would be (c++)and what would be (++c)
if c=12 then c++ + ++c is 12 + 14 = 26, so 26 will be assigned to c.
First the c++ is evaluated to 12 and then 13 is assigned to c. Then ++c first assigns 13+1 is 14 to c and results in 14. So we have 12 + 14 which is the result of the expression and is assigned to c again.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Can someone tell me how I'd go about creating a custom percentage scale for an android app? For example, if I'd like 65 (or below) to be 0% and 315 (or above) to be 100%, and I input 255 it would give me a percentage value based on this scale.
This is just a mathematical question.
if (value < 65) {
return 0;
}
if (value > 365) {
return 100;
}
return (value - 65 / (365 - 65)) * 100;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
while (in > h-1 && n[in-h] >= wrapperTemp)
I am writing a program but it deals with objects, so using the >,>=, symbols aren't going to help me in this case.
in, h, and wrapperTemp are all variables.
- this is written in the java language
I think you just want this
while (in.compareTo(h-1) > 0 && n[in-h].compareTo(wrapperTemp) >= 0)
Try,
while (in > h-1 && (n[in-h].compareTo(wrapperTemp) >=0))
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Hi in the below code mandatoryCount = 0 and it should be increased when an image is selected but its found to be always 1 and i cant exit the loop can any one help me. Here if mandatoryCount = 0 or mandatoryCount>=imageTypeMandatory.length. It must come out of loop. But this code is working if i comment the mandatory count ==0. I cannot find the exact error.
if (dataOne.getCount() >= 1) {
mandatoryCount=0;
dataOne.moveToFirst();
while(!dataOne.isAfterLast()){
for(int iCopy=0;iCopy<imageTypeMandatory.length;iCopy++){ if(imageTypeMandatory[iCopy].trim().equalsIgnoreCase(dataOne.getString(0).trim())){
mandatoryCount++; imageTypeMandatoryCopy[iCopy]="";
}}
dataOne.moveToNext();
}
The logic is testing the moveFirst/moveNext.
if (dataOne.moveToFirst()) {
do {
for(int iCopy=0;iCopy<imageTypeMandatory.length;iCopy++){
if(imageTypeMandatory[iCopy].trim().equalsIgnoreCase(dataOne.getString(0).trim())){
mandatoryCount++;
imageTypeMandatoryCopy[iCopy]="";
}
}
} while(dataOne.moveToNext());
}