QUESTION IMAGE
Question
activity 2.9.1: using constants in expressions. the cost to ship a package is a flat fee of 75 cents plus 25 cents per pound. organize the correct code statements to: 1. declare a constant integer variable named cents_per_pound and initialize the constant with the value 25. 2. read the shipping weight from input and store the weight into shipweightpounds. 3. assign shipcostcents with the cost of shipping a package weighing shipweightpounds. use the constants flat_fee_cents and cents_per_pound. click here for example ^ ex: if the input is 10, then the output is: weight(lb): 10 flat fee(cents): 75 cents per lb: 25 shipping cost(cents): 325 note: not all code statements on the left will be used in the final solution. how to use this tool v unused hipweightpounds = scnr.nextint(); hopcostcents = flatfeecents + (centsperpound shipweight hipcostcents = flat_fee_cents + (cents_per_pound shipwe onstant int cents_per_pound = 25; inal int cents_per_pound = 25; onst int cents_per_pound = 25; shippingcalculator.java load default template... 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; system.out.println(\weight(lb): \ + shipweightpou system.out.println(\flat fee(cents): \ + flat_fee system.out.println(\cents per pound: \ + cents_pe system.out.println(\shipping cost(cents): \ + shi } }
Step1: Declare constant for cents per pound
final int CENTS_PER_POUND = 25;
Step2: Read shipping weight
shipWeightPounds = scnr.nextInt();
Step3: Calculate shipping cost
shipCostCents = FLAT_FEE_CENTS + (CENTS_PER_POUND * shipWeightPounds);
Here is the complete code:
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;
final int CENTS_PER_POUND = 25;
shipWeightPounds = scnr.nextInt();
shipCostCents = FLAT_FEE_CENTS + (CENTS_PER_POUND * shipWeightPounds);
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);
}
}Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
The above - provided Java code is the solution to calculate the shipping cost as per the given requirements.