2. Write a java program named StampCalc.java. This program will input 3 int 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, and 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: 5 2 6
Your output should show just one line:
The total for 5 First Class stamps, 2 additional ounces and 6 International stamps is $9.82
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int a,b,c;
Scanner in=new Scanner(System.in);
System.out.println("Enter three numbers: ");
a=in.nextInt();
b=in.nextInt();
c=in.nextInt();
System.out.println("The total for "+a+" First Class stamps, "+b+" additional ounces and "+c+ " International stamps is $"+((a*0.50)+(b*0.21)+(c*1.15)));
}
}
Comments
Leave a comment