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: Sample run 2:
java lab02_task02 12 3 java lab02_task02 2 5
Output: 9 36 Output: -3 10
1
Expert's answer
2021-09-14T07:35:51-0400
public class lab02_task02 {
public static void main(String[] args) {
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
System.out.println(x - y + " " + x * y);
}
}
Comments
Leave a comment