+ 1

Java simple shipping cost help ?

####This is what I have#### 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; shipCostCents = (CENTS_PER_POUND * shipWeightPounds) + FLAT_FEE_CENTS; 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); } } #### this is the error I get### ShippingCalculator.java:12: error: variable shipWeightPounds might not have been initialized shipCostCents = (CENTS_PER_POUND * shipWeightPounds/4) + FLAT_FEE_CENTS; ^ 1 error ###I am only able to edit these two strings below### final int CENTS_PER_POUND = 25; shipCostCents = (CENTS_PER_POUND * shipWeightPounds) + FLAT_FEE_CENTS; what am I missing?

9th Feb 2021, 5:04 PM
Gutz_X_73vEn
Gutz_X_73vEn - avatar
1 ответ
+ 1
shipWeightPounds is not initialized. You never assigned a value to it
9th Feb 2021, 5:17 PM
♡Addy♡
♡Addy♡ - avatar