Friday, August 16, 2013

Java Program 004

write a Program DisplayNumbersDemo1.java, which accepts Three int values as command line arguments (Start value End value and Increment value) and print the number between the given Numbers.

Ex:    Input: 10, 30, 2

Output: 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30

// Author		: J. Srivastav Reddy
// Date : 30-7-2013

public class DisplayNumbersDemo1
{
public static void main(String[] args)
{
int start = Integer.parseInt(args[0]);
int stop = Integer.parseInt(args[1]);

for(;start <= stop;)
{
System.out.print(start + " ");
start += Integer.parseInt(args[2]);
}
}
}

No comments:

Post a Comment