Answer to Question #236279 in Java | JSP | JSF for guru

Question #236279

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 1


1
Expert's answer
2021-09-12T11:49:03-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);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS