Write a program named TotalPrice.java. Your program takes two number from the Cm
ID: 3742085 • Letter: W
Question
Write a program named TotalPrice.java. Your program takes two number from the Cmd argument list, N and P, N is the number of product and P is the unit price of the product. Your program will calculate and display total cost. For example, if you input 4 5 then your program output: Total Cost=20
Write a program named TotalPrice.java. Your program takes two number from the Cmd argument list, N and P, N is the number of product and P is the unit price of the product. Your program will calculate and display total cost. For example, if you input 4 5 then your program output: Total Cost=20
Explanation / Answer
public class TotalPrice { public static void main(String[] args) { if(args.length >= 2) { int N = Integer.parseInt(args[0]); int P = Integer.parseInt(args[1]); System.out.println("Total Cost=" + (N*P)); } } }