|
Until you sign up you can't do much. Yes, it's free.
|
|
|
|
|
|
|
 | / / / Viewing Topic
|  |
( Brookie Chookie23 )
Swami
Patron
Tech Support Leader
|
Hi. I'm doing a Java assignment for my IT class. It's a pretty simple assignment, but what's coding without errors, huh? The scenario: I have to design a program which acts as a pay machine for a parking lot. Two of the objective that program has to achieve are to calculate how long the visitor stayed in the car park, and to calculate how much the visitor owes. I have done some code which achieves both of these objectives in a separate java file for testing purposes, and it worked. The problem is, when I put it into the script with all my GUI stuff, it didn't calculate the amount owing correctly. I have discovered that this problem has something to do with where the values for month, day, hour, minute, second, etc are intialised. I have used two if functions which set values for the date and time that the car was parked depending on what parking ID the user inputs. These variables were initalised globally, i.e: | Code: | public static int year=0; public static int month=0; public static int day=0; public static int hour=0; public static int minute=0; public static int second=0; | My if functions look like this: | Code: | if(inputID==ID1){ year=data[6]; month=data[5]; day=data[4]; hour=data[3]; minute=data[2]; second=data[1]; } if(inputID==ID2){ year=data[13]; month=data[12]; day=data[11]; hour=data[10]; minute=data[9]; second=data[8]; //sets date & time variables from array to according to ID entered } | From what I can see, neither of the if functions are being executed, because the calculated cost is something ridiculous (5.8... x e^70), and when I tried removing the if functions from my test java file, it produced that same number. I don't know how many (if any) java geeks we have on LiveWire, but if you are one I'd greatly appreciate your help. I can send you both the test script and the program script if it helps you understand more about the problem.
------- Check out my: Art|Moozics|Store Need help with photography or graphic design? Ask me!
|
|
|
|
|
 LiveWire Humor
|
|
|
|
|
|
vector3df
Professional
|
Now trying printing the inputID and ID1 to the screen. Put it just before your if statements.
------- Duke By the Grace of His Majesty the King of the United Kingdom of Deep Thoughts and Random Musings, Defender of the Faith
|
|
|
|
|
|
|
|
|
|
|
|
| Looking for something else?
|
|
|
|
|
|
 | / / / Viewing Topic |  |
|