Answer to Question #235826 in Java | JSP | JSF for java

Question #235826


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




1
Expert's answer
2021-09-10T23:52:17-0400
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)));
	}
}

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
New on Blog
APPROVED BY CLIENTS