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 5 days ago.
Improve this question
So my program is working , the program is to check if a number is Automorphic,Trimorphic,Tri-Automorphic or its not a type of automorphic.
But I have a doubt , that is , what does this do:
for (I = a ; I> 0 ; I = I / 10 )
{
C++;
}
I tried to remove C++ but that didn't work.
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 1 year ago.
Improve this question
public String createHash()
{
String[] ALPHABET={"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
String[] hash={"0","1","2","3","4","5","6","7"};
for(int var=0; var==61; var++)
{
hash[7]=ALPHABET[var];
System.out.print(hash[7]);
}
return "Success";
}
I'm not quiet sure how to explain what this code is supossed to do but I hope you get what I wanted it to do. It's supposed to take the value behinde index 7 of hash and replace it with the value behinde index "var" of ALPHABET.
So at the end it should print in the cosole something like this: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
I'm not sure where the error is. It's probabbly something extremly basic but I'm quiet new to programming...
You're seeing "Success", aren't you? This may be because of the abort-variable. var is never 61 because this condition will be checked before your for-block is executed.
It will has to be
for(int var = 0; var <= 61; var++)
if you want 62 executions of your for loop.
Anyway, I don't understand the purpose.
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 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 5 years ago.
Improve this question
I want to make a method return that return several times a String from a list of String. any idea ??
How about something like this:
String getRandomString(List<String> list) {
return list.get(new Random().nextInt(list.size()));
}
This isn't the most efficient way, but should do the job.
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
For (int i=1; i <=n;i/=2){
System.out.println(i);
}
For the time complexity about the above coding, is ot log (n)?
Thanks!
If n > 0: It's time complexity is O(∞) because the loop will never end
If n <= 0: It's time complexity is O(1)
because the loop will not be executed