Initializing doubles in a loop giving error “variable might not have been initialized”
This program is supposed to get the weight of some mail from the user and calculate how much it costs. After 100g, the cost increases by $2.5/50g. However, when I try to run the program, it says "variable cost might not have been initialized". Is this because I am initializing it in an if statement or something? I know some people have had errors because they declare the variable in the if statement, but I have declared my variable outside the if statement. What am I doing wrong?