don't know how to use the command line arguement
here're my 2 programs which worked well in console
1given two integer numbers you will see the result of their sum/difference/product/quotient(only the integer part)/mod
import java.util.Scanner;
public class Numbers
{
public static void main(String[] args) {
Scanner putin = new Scanner (System.in);
int a = putin.nextInt();
int b = putin.nextInt();
System.out.println(a + b);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b);
System.out.println(a % b);
}
}
2、it will be two sentences when it comes to the results
import java.util.Scanner;
public class Greetings {
public static void main(String[] args) {
Scanner keyboard = new Scanner (System.in);
String a = keyboard.next(), b = keyboard.next();
System.out.println("Hello " + a +" from " + b + ".");
System.out.print("I'VE ALWAYS WANTED TO GO TO");
System.out.println(b.toUpperCase() + ".");
}
}
but i need to use the command line argument to make it test well in Unix, I don't understand how to translate the program so that it can work well with the command line argument. can you help me with it?
Re: don't know how to use the command line arguement
Please have a look at this tutorial which explains how to get and use command line arguments.
Re: don't know how to use the command line arguement