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)); } } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.