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_POUN
Posted: Mon Jun 06, 2022 5:09 pm
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.
import java.util.Scanner;
public class ShippingCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int shipWeightPounds;
int shipCostCents = 0;
final int FLAT_FEE_CENTS = 75;
" /* Your solution goes here */ "
System.out.println("Weight(lb): " + shipWeightPounds);
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);
}
}
CHALLENGE ACTIVITY 2.8.1: Using constants in expressions. The cost to ship a package is a flat fee of 75 cents p cents per pound. 1. Declare a constant named CENTS_PER_POUND a initialize with 25. 2. Get the shipping weight from user input storing th into shipWeightPounds. 3. Using FLAT_FEE_CENTS and CENTS_PER_POUN[ constants, assign shipCostCents with the cost of sh package weighing shipWeightPounds. 396146.2628362.qx3zqy7 1 import java.util.Scanner; 2 4 5 3 public class ShippingCalculator { public static void main(String[] al Scanner scnr = new Scanner (Syst int shipWeight Pounds; int shipCost Cents = 0; 6 7 8 final int FLAT_FEE_CENTS = 75; 9 10 /* Your solution goes here */ 11 12 13 System.out.println("Weight (lb): System.out.println("Flat fee(cel System.out.println("Cents System.out.println("Shipping 14 per p co: 15 16 } 17 }
2.8.1: Using constants in expressions. to ship a package is a flat fee of 75 cents plus 25 pound. e a constant named CENTS_PER_POUND and with 25. e shipping weight from user input storing the weight WeightPounds. FLAT_FEE_CENTS and CENTS_PER_POUND s, assign shipCostCents with the cost of shipping a weighing shipWeight Pounds. 362.qx3zqy7 r; ilculator { ain(String[] args) { w Scanner (System.in); inds; ; = 0; :E_CENTS = 75; goes here */ .n("Weight (lb): " + shipWeight Pounds); n("Flat fee (cents): + FLAT_FEE_CENTS); .n("Cents per pound: + CENTS_PER_POUND); .n("Shipping cost (cents): " + shipCostCents);
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.
import java.util.Scanner;
public class ShippingCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int shipWeightPounds;
int shipCostCents = 0;
final int FLAT_FEE_CENTS = 75;
" /* Your solution goes here */ "
System.out.println("Weight(lb): " + shipWeightPounds);
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);
}
}
CHALLENGE ACTIVITY 2.8.1: Using constants in expressions. The cost to ship a package is a flat fee of 75 cents p cents per pound. 1. Declare a constant named CENTS_PER_POUND a initialize with 25. 2. Get the shipping weight from user input storing th into shipWeightPounds. 3. Using FLAT_FEE_CENTS and CENTS_PER_POUN[ constants, assign shipCostCents with the cost of sh package weighing shipWeightPounds. 396146.2628362.qx3zqy7 1 import java.util.Scanner; 2 4 5 3 public class ShippingCalculator { public static void main(String[] al Scanner scnr = new Scanner (Syst int shipWeight Pounds; int shipCost Cents = 0; 6 7 8 final int FLAT_FEE_CENTS = 75; 9 10 /* Your solution goes here */ 11 12 13 System.out.println("Weight (lb): System.out.println("Flat fee(cel System.out.println("Cents System.out.println("Shipping 14 per p co: 15 16 } 17 }
2.8.1: Using constants in expressions. to ship a package is a flat fee of 75 cents plus 25 pound. e a constant named CENTS_PER_POUND and with 25. e shipping weight from user input storing the weight WeightPounds. FLAT_FEE_CENTS and CENTS_PER_POUND s, assign shipCostCents with the cost of shipping a weighing shipWeight Pounds. 362.qx3zqy7 r; ilculator { ain(String[] args) { w Scanner (System.in); inds; ; = 0; :E_CENTS = 75; goes here */ .n("Weight (lb): " + shipWeight Pounds); n("Flat fee (cents): + FLAT_FEE_CENTS); .n("Cents per pound: + CENTS_PER_POUND); .n("Shipping cost (cents): " + shipCostCents);