can anyone tell
how to write in core java using command line arguments :
a) to print prime numbers from 1 to n
b) to calculate the length of input string
c) to find whether the number is odd or even
d) to convert dollar in rupees
e) to accept 3 command line arguments from users and display it in the sorted order

f) to accept string and interchange the first character with the last character

Your gonna have to make some sort of attempt here, no will really give you all the code you need.

COMMAND LINE:

> java YourClass arg1 arg2 "arg3 arg4"

public class YourClass {
   public static void main(String [] [B]args[/B]) {

      System.out.println("Number of Arguments: "+[B]args[/B].length);       

      for (int i=0;i<[B]args[/B].length;i++) {
           System.out.println([B]args[/B][i]);
      }
   }
}

The arguments at the command line are passed in the args array. If no arguments given, it has length 0. It is never null.

The above will return:

Number of Arguments: 3
arg1
arg2
arg3 arg4 // this is the third argument. The double quotes allow you to have spaces inside an argument

Use for loops, take a look at the String class API, use the '%' operator, post code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.