Answer to Question #237414 in Java | JSP | JSF for WhitneyTrev

Question #237414

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


1
Expert's answer
2021-09-15T11:41:53-0400


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));
		}
	}
}

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
APPROVED BY CLIENTS