The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound. 1.
ID: 3915175 • Letter: T
Question
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. Using FLAT_FEE CENTS and CENTS_PER POUND constants, assign shipCostCents with the cost of shipping a package weighing shipWeightPounds. 1 import java.util.Scanner; 3 public class ShippingCalculator 4 public static void main (String args) int shipWeightPounds -10; int shipCostCents 0; final int FLAT-FEE-CENTS = 75; * Your solution goes here 10 12 13 14 15 16 System.out.println"Weight(lb): "shipWeightPounds); System.out.printlnC Flat fee(cents): " FLAT_FEE_CENTS); System.out.printlnC"Cents per pound: "CENTS_PER_POUND); System.out.printlnc" Shipping cost(cents): " shipCostCents);Explanation / Answer
Solution:
output:
Weight(lb) : 325
Flat fee(cents) : 75
Cents per pound: 25
Shipping cost(cents) : 325
{
public static void main(String[] args)
{
int shipWeightPounds = 10;
int shipCostCents = 0 ;
final int FLAT_FEE_CENTS = 75;
final int CENTS_PER_POUND = 25;
shipCostCents = FLAT_FEE_CENTS + (CENTS_PER_POUND * shipWeightPounds);
System.out.println("Weight(lb) : " + shipCostCents);
System.out.println("Flat fee(cents) : " +FLAT_FEE_CENTS);
System.out.println("Cents per pound: " +CENTS_PER_POUND);
System.out.println("Shipping cost(cents) : " +shipCostCents);
}
}
output:
Weight(lb) : 325
Flat fee(cents) : 75
Cents per pound: 25
Shipping cost(cents) : 325
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.