Write a java program named StampCalc,java. This program will input 3 values from
ID: 3745003 • Letter: W
Question
Write a java program named StampCalc,java. This program will input 3 values from the command-line. The first will represent the number of First Class stamps requested, the second number will indicate the number of Additional Ounces needed for those first class letters, and the third number will indicate the number of International stamps requested. The cost for First Class stamps is $.50 The cost for an Additional Ounce is $.21 The cost for an International stamp is $1.15 Your program will calculate the total cost for the requested number of stamps. If the command-line values were: 526 Your output should show The total for 5 First Class stamps, 2 additional ounces and 6 International stamps is $9.82Explanation / Answer
public class StampCalc { public static void main(String[] args) { int firstClass = Integer.parseInt(args[0]); int additional = Integer.parseInt(args[1]); int international = Integer.parseInt(args[2]); double total = (0.5 * firstClass) + (0.21 * additional) + (1.15 * international); System.out.printf("The total for %d First Class stamps, %d additional ounces and %d International stamps is $%.2f ", firstClass, additional, international, total); } }
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.