DIGIT-ARC read-only archive · snapshot: July 23, 2026

help in java homework anyone?

12 posts · originally from https://geek.digit.in/community/threads/help-in-java-homework-anyone.78342/

entrana
entrana Original post #1
Jan 16, 2008 at 9:35 AM
i need a simple program, i think using for loop, to find odd numbers till a specified number using command line argument. like i want to find out all odd numbers till 10.
entrana
entrana #2
Jan 17, 2008 at 2:57 PM
aww cmon im sure u people know java
QwertyManiac
Jan 17, 2008 at 6:15 PM
Code:
class Odd
{
    public static void main(String args[])
    {
        int i=Integer.parseInt(args[0]);
        for(int count=1;count<=i;count+=2)
        {
            System.out.println(count);
        }
    }
}

Execute:
Code:
java Odd 9
Output:
Code:
1
3
5
7
9
Pathik
Pathik #4
Jan 17, 2008 at 6:27 PM
Qwerty man how many languages do u know???
Pathik
Pathik #6
Jan 17, 2008 at 7:08 PM
Just asking. Cos you r very good at programming. :)
entrana
entrana #7
Jan 18, 2008 at 9:54 AM
thanks
QwertyManiac
Jan 18, 2008 at 5:30 PM
What did you find difficult in writing this one that you had to ask though?

Or is it just laziness? :p
entrana
entrana #9
Jan 20, 2008 at 3:11 PM
couldnt figure out that count+=2 thing. i was trying count+2
casanova
casanova #11
Jan 20, 2008 at 3:40 PM
count+=2 is similar to count=count+2
redhat
redhat #12
Jan 23, 2008 at 3:32 PM
@entrana : I suppose ur still in school...

What grade are u in?
PM me....