Respuesta :
Answer:
// Here is code in Java.
// import package
import java.util.*;
// class definition
class Main
{
// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// variables
final int CENTS_PER_POUND = 25;
final int FLAT_FEE_CENTS = 75;
// Scanner object to read input
Scanner sr=new Scanner(System.in);
System.out.print("Enter the shipping weight:");
// read the input weight
int shipWeightPounds=sr.nextInt();
// calculate total cost
int shipCostCents = (shipWeightPounds * CENTS_PER_POUND) + FLAT_FEE_CENTS;
// print Weight
System.out.println("shipping Weight: " + shipWeightPounds);
// print flat fee
System.out.println("flat fee of shipping in cents : " + FLAT_FEE_CENTS);
// print cents per round
System.out.println("Cents/pound for shipping: " + CENTS_PER_POUND);
// print cost of Shipping
System.out.println("total cost of shipping in cents: " + shipCostCents);
}catch(Exception ex){
return;}
}
}
Explanation:
Declare and initialize two constant variables "CENTS_PER_POUND=25" & "FLAT_FEE_CENTS = 75". Read the input weight from user with the help of Scanner class object. Then calculate the cost of shipping by multiply weight with cent per pound and add flat fee. Then print each of them.
Output:
Enter the shipping weight:12
shipping Weight : 12
flat fee of shipping in cents: 75
Cents/pound for shipping: 25
total cost of shipping in cents: 375
Answer:
final int CENTS_PER_POUND = 25;
shipWeightPounds=scnr.nextInt();
shipCostCents = ((shipWeightPounds * CENTS_PER_POUND) + FLAT_FEE_CENTS);
Explanation: