The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.
1. Declare a constant named CENTS_PER_POUND and initialize with 25.
2. Get the shipping weight from user input storing the weight into shipWeightPounds.
3. Using FLAT_FEE_CENTS and CENTS_PER_POUND constants, assign shipCostCents with the cost of shipping a package weighing shipWeightPounds.

Respuesta :

ijeggs

Answer:

import java.util.Scanner;

public class ShippingCost {

   public static void main(String[] args) {

      final int FLAT_FEE_CENTS = 75;

       final int CENTS_PER_POUND = 25;

       Scanner in = new Scanner(System.in);

       System.out.println("Please enter the weight of the package");

       double shipWeightPounds = in.nextDouble();

       double shipCostCents = (CENTS_PER_POUND*shipWeightPounds)+ FLAT_FEE_CENTS;

       System.out.println("The Total Shipping cost of the package in cents is "+ shipCostCents);

   }

}

Explanation:

In Java language, the two given constants are declared using Java's final keyword indicating a constant value. The Scanner class is used to prompt and receive users' input for the weight of the shipment. The value is stored as shipWeightPounds. Understanding that shipping costs 25 cents per pound in addition to the flat rate of 75 cents, this statement,

shipCostCents = (CENTS_PER_POUND*shipWeightPounds)+ FLAT_FEE_CENTS;

Computes the cost of the entire package.

fichoh

The shipping cost ; shipCostCents = FLAT_FEE_CENTS + (shipWeightPounds × CENTS_PER_POUND)

The shipping cost can be calculated thus :

Flat fee + (Weight of package × cost per pound

Using Python 3 :

#Declaring the constant fee per pound = 25 cent

CENTS_PER_POUND = 25

#Takes input from the user, the weight in pounds of the package.

shipWeightPounds = eval(input("Weight of your package"))

FLAT_FEE_CENTS = 75

shipCostCents = FLAT_FEE_CENTS + (shipWeightPounds × CENTS_PER_POUND)

Print(shipCostCents)

Learn more : https://brainly.com/question/19625875?referrer=searchResults

Q&A Education