Need Help Finding out problem with my code?! Please help!
This Program is basically prompting the user to enter information such as name,address,province,city,country etc and then validating the information,
I have two functions, one called promptInformation which takes in the name,address,province,city,country and postal code, this function basically prompts the user information, my other function validate information has the same parameters as prompt information, this function basically checks to see if the name,address,province,city,country and postal code are entered and if they are then it checks the country variable and if the country variable is canada it displays the name,address,province,city,country and postal code in red, and if its US it displays the information in blue.
My problem is when the user does enter the correct information it isnt going into the else block? why is that? I changed the null to "" one time and it did go into the else block but it didnt go into the check for the country, so what is the problem here?
Here is my code:
The WHILE statement makes this an infinite loop.
The if(name==null ||name=="" || country==null......... will make this go back to entering info and the person entering info will not know why.
You made the variables GLOBAL, you don't need to pass them into the functions.
promptInformation(); will call the function and function promptInformation() and function validation() are good to go because they know the variables already.
And also without looking at the code I wouldn't have known I needed to input us or US to get this to show blue.
I suggest you evaluate each input as soon as it's entered if it's wrong or non existent tell the user why and ask for the input again. Then go into the red/blue printing.
|All times are GMT +1. The time now is 02:23 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.