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;
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 2 years ago.
Improve this question
Write a Java program that keeps a number from the user and generates an integer between 1
and 7 and displays the name of the weekday.
Create a Strint array with all weekdays ({"Sunday", "Monday"...}) and than get the name by index like this:
int day = 2;
System.out.println(weekdays[day - 1]);//output Monday
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.");
}
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
What is the equivalent Java code of this MATLAB code: ran = sign(rand-0.5)?
Is it randomly assigned either 1 or -1 to ran? Should I used a Pseudo random number generator that generates randomly 1 or -1?
Random rand = new Random(key);
ran = rand.nextInt(1);
double ran = Math.signum(Math.random() - 0.5);
The variable ran will contain +1, -1 or sometimes 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
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))