help in java homework anyone?

Status
Not open for further replies.

entrana

M$™ Certified Spammer
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.
 

QwertyManiac

Commander in Chief
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
 
Status
Not open for further replies.
Top Bottom