Create a program that when run with two numbers as CMD arguments, it prints out the difference
and product separated by space[Hint: CMD arguments need to be converted to integers]:
Sample run 1:
java lab02_task02 12 3
Output: 9 36
Sample run 2:
java lab02_task02 2 5
Output: -3 10
public class Main {
public static void main(String[] args) {
if (args.length > 0) {
int number1 = Integer.parseInt(args[0]);
int number2 = Integer.parseInt(args[1]);
System.out.println((number1 - number2) + " " + (number1 * number2));
}
}
}
Comments
Leave a comment