# loop « Number « Java Data Type Q&A

### 1. Display numbers from 1 to 100 without loops or conditions    stackoverflow.com

Is there a way to print numbers from 1 to 100 without using any loops or conditions like "if"? We can easily do using recursion but that again has an if condition. ...

### 2. Java: minimum number of operations for conjunctive inequalities?    stackoverflow.com

I try to simplify conditionals in:

``````for ( int t=0, size=fo.getPrintViewsPerFile().size();
t<size && t<countPerFile;
...``````

### 3. How can I optimise my awful code for finding the highest palindrome of a 3 digit number?    stackoverflow.com

This is what I have written so far. It compiles, and, as far as I can tell, it should 'work' - if you were to give your computer an infinite amount ...

### 4. In Java: How do I execute a distinct number of methods sequentially?    stackoverflow.com

Possible Duplicate:
How do I invoke a java method when given the method name as a string?
I have a few methods `myMethod0() ... myMethodN()`, where ...

### 5. How can we find out the number of times the while loop lasted    stackoverflow.com

``````while((MAP = inputFile.readLine()) != null) {
System.out.println(MAP);
}
``````
How can we find out the number of iterations performed by the while loop? In this textfile, they can be sometimes 5 ...

### 6. Perfect numbers 1 to n    stackoverflow.com

Write an algorithm that prints perfect numbers from 1 to n. To determine if a number is perfect add up all the factors of the number that are less ...

### 7. Finding the Average from a list of numbers in Java    stackoverflow.com

This is my first attempt at java problem I have been given as part of my Programming assignment. I must make a program which calculates the average of a list of numbers ...

### 8. Return the number of people in the list with a name that matches the parameter using a for-each loop    stackoverflow.com

this is my attempt at it. it doesnt pass the test for some reason.

``````public ArrayList<Person> people;

public int count(String name){
int sum = 0;
...``````

### 9. Palindrome in Java with NUmbers    stackoverflow.com

I am self studying java, i am on while loops already, I have an exercise here regarding a palindrome. what's a palindrome? how will code it? any ideas? or pseudocode for ...

### 10. Prime Numbers III Problem 18 - I dont get the right answer even though I think I am right    stackoverflow.com

I am new here. I am trying to solve this exercise Problem 18 just for reinforcing my solving skills. I've already coded the answer. The task asks ...

### 11. Using a for-loop to print numbers    stackoverflow.com

I'm trying to write a program that prints all numbers from 0 to 1,000 where the number mod 5 = 3. This is what I have so far

``public class NewMain ...``

### 12. U.S. Phone Number Validation Question    stackoverflow.com

I'm having trouble with this code for my class : Here are the problems 1.) It does not Loop after success (the code compiles but the when it asks "what is your number?" ...

### 13. Create a loop that loop for x number of seconds. How ?    coderanch.com

Well I look around a lot but I havent find anything that I think might work. I look at java.util.Timer as well as java.Time but no luck there. If you can point me in the right direction then I would appreciate it very much. Here is roughly what I want. loop(10 seconds) { //Display random images. Eventually I want to create ...

### 14. How to Determine prime number and making shape using loop?    java-forums.org

It's not wrong to only put a question, but people here want to help you learn java, not do homework for you. we usually feel that by answering broad questions like "how to make a program that does ..." is doing homework for the asker, and does not teach them anything. We are more inclined to answer questions that have to ...

### 15. Writing a program to crack a PIN number using nested for-loops    java-forums.org

Hey I need help forming this program in my intro java programming class. Here;s what I have to do: Write a program called CrackPIN (use nested for-loops) that guesses the PIN in the file. I already created a .txt file in notepad with the pin. I actually even formed the .txt file through a program because that was the previous task ...

### 16. Adding squared numbers in a loop    java-forums.org

ok ill try to explain my problem as best as i can. Im required to create a program that sums up the squares beginning from 1 to the number the user entered, for example the number is 3 so the output will be 14 (because 1squared +2squared+ 3squared or 1+4+9=14) so far here is what i got int num; System.out.println ("Please ...

### 17. Loop through all letter and number possibilities?    java-forums.org

What I mean is how do i make a loop in java that cycles through all possible combinations of letters and numbers (with a limit of course). Like have it start with 0 and next have it be 00, 000, 0000... And then after like 5 digits of zeros have a 1 added (00001) And continue on adding letters. I realize ...

### 20. for loop to create "n" number of Ellipse    forums.oracle.com

What are you talk petes1234 I do need you help, if I didnt I wouldnt have posted my question here. Thank you Quacked. You were a lot of help and you helped me learn alot. I now have a deeper understanding of how the Java language works. Peters1234 thanks for not helping and obstructing my learning process. Perhaps I had a ...

### 21. For Loop to print odd numbers from 1-99 inclusive    forums.oracle.com

Hello, im new here and i need help..i need a for loop that prints the odd numbers from 1 to 99 inclusive (including 1 and 99) also i need a for loop that prints the multiples of 3 from 300 down to 3. also inclusive. If anyone can help me out, id love it, thanks =)

### 23. drawing numbers inside table using nested for loop    forums.oracle.com

yes i am getting the numbers inside the recatnage but not in proper fashion. i need the number in the followin fashion, 1st row 1 2 3 4 5 6 7 8 9 2nd row 2 4 6 8 10 12 14 16 18 3rd row from 3--upto 27-- 4th row from 4-upto-36 and so on until 9th row 9 18 ...

### 25. for loop to get the largest number    forums.oracle.com

hi there how do i write a for loop to get the largest number in the loop..this loop is dynamic..thank you In addition to the other comments (try it and post your efforts; communicate your problem more clearly and precisely), think about how you'd do it by hand. Assume you have a bunch of cards with different numbers on them, and ...

### 26. Spacing in number triangle using for loops    forums.oracle.com

thomp2bl wrote: Hello I have a number triangle thing that looks like the one bellow but can't figure out how to put spaces in it. When I add a plus sign to System.out.print(y plus " ") it makes a pyramid and not a triangle. That's because now, you're printing out a single space for each number that's in the bottom row ...

### 27. How to get numbers within a range without looping?    forums.oracle.com

Here's a guess: suppose I have a truck load of integers in an array and some expensive to compute condition. All I know is that the array elements that satisfy the condition lie in a contiguous section of the array. I don't really want "to get the integers" - in fact I already have them in the array! - what I ...

### 29. Prime Numbers Using For Loops    forums.oracle.com

Yes, someone showed me StringBuilder, I just haven't used it yet because it's not used in the text I'm following and I've just been using the text's methods. I'm going to try and get in the habit of using StringBuilder, perhaps not right off the bat though. That article was interesting; I appreciate the read. Aside from poor String concatenation, what ...

### 32. method that has a loop that exports a number    forums.oracle.com

System.out.println(" The final value of the loop counting to ten is " + Emily.UpCounter() ); System.out.println(" The incrementing values of the loop counting to ten are " + Emily.countToTen()); /// The line above prints the final returned value of public double UpCounter() /// What I am trying to figure out is how to carry the indexing or counting value back into ...

### 34. do while loop to stop random number repeating    forums.oracle.com

RandCount[number] will never be 0 since inside the do you check if it equals 0 and set it to 1. Also you should check the uniqueness of the random number before reading from the file. There is no need to read from the file if the question was already used. And use a HashSet, that's exacly what it was invented for. ...