I'm trying to write a program that displays an appropriate shipping charge based on zip code entered by the user.
To be valid the ZIP code must contain exactly 5 digits and the first three digits must be “605”, or “606”. The shipping charge for the “605” ZIP code is $25.00. The shipping charge for the “606” ZIP code is $30.00.
Dude you could just have them enter the zip code regularly like 60648 and then do a substr(0,2) or substr(0,3) not sure which to get the string '606' or '605'. thats how i would do it.
I'm trying to equate a zipcode that starts with "606"to have a shipping charge of $25.00 and
equate a zipcode that starts with "605" to have a shipping charge of $30.00.
make sense?
he's a little update but still getting errors aroung the shipping charges
no it will accept anything as the first 3 integers, if its a requirement why don't you just have a menu selection where they can choose what their zip code starts with ie( 1. 606, 2. 605, 3. other) ((you would probably do nested if statments for this like if(selection==1){body} else if(selection==2){body} else{quit program})) then if they choose other ie 3 then quit the program. if they choose 1 then go from there and if they choose 2 go from there.
if you want to stick with that you got your on the right track with your code your errors are with the if else if.
if you are not going to have a else that goes with the if else if then I would just make the else if an else.
Here is the code for your first if you can do the 2nd
If the zip code thing is a requirement just make an else after the if else if and have an error message saying "your zip code does not start with the required 606 or 605." or something if its a big deal
Line 29: Else-if and you have a semi-colon that shouldn't be there. Furthermore, you're missing some curly brackets. That said, you'll also need an else block to deal with invalid area codes around that area. :)