ClanKiller.com https://forums.clankiller.com/ |
|
anyone here do Java? https://forums.clankiller.com/viewtopic.php?f=24&t=1155 |
Page 1 of 4 |
Author: | derf [ Mon Feb 21, 2005 1:25 pm ] |
Post subject: | anyone here do Java? |
Author: | Pig [ Tue Feb 22, 2005 8:52 am ] |
Post subject: | |
Author: | derf [ Tue Feb 22, 2005 9:09 am ] |
Post subject: | |
Mmm, your idea seems to be ok, but now it sais the char "continuing" variable has not been initialised. WTF, yes it has, its in bold BTW. ****************************************** public static void main(String args[]) { String studentNumber; Student thisStudent; boolean continuing = true; char response; char selection; while (continuing == true) selection = IO.readChar(version + "\n\nPlease input 1, 2, 3 or 4"); switch (selection) { case '1': // do this do that blah blah... ... ... ***************************************************** |
Author: | Pig [ Tue Feb 22, 2005 9:32 am ] |
Post subject: | |
Author: | derf [ Tue Feb 22, 2005 9:37 am ] |
Post subject: | |
Sorry, i meant selection has not been initialised //EDIT - Fixed this, i added some brakets for the WHILE loop. Though, the damn thing doesnt loop!!! //EDIT - Now it does. I removed a semi-colon. THANKS PIGGIE FOR THE ADVICE ON THE == OPERATOR!!! *KISSES PIGS LOVELY THIGHS* |
Author: | Pig [ Tue Feb 22, 2005 9:46 am ] |
Post subject: | |
Some languages keep a variable within level it is defined. Moving into a deeper or shallower level of brackets make the var go out of scope. eg: str var = 'foo'; print var; //returns 'foo' for(;;) { printvar; //undefined str var = 'bar'; print var; //returns 'bar'; } print var; //returns 'foo' Again, I don't know if java is like this, but try initializing the variable within the brackets you are using it. |
Author: | Pig [ Tue Feb 22, 2005 9:47 am ] |
Post subject: | |
good deal. Thanks for the kisses. |
Author: | ElevenBravo [ Tue Feb 22, 2005 10:30 am ] |
Post subject: | |
Author: | derf [ Tue Feb 22, 2005 10:36 am ] |
Post subject: | |
Author: | Pig [ Tue Feb 22, 2005 11:41 am ] |
Post subject: | |
ROFL |
Author: | derf [ Wed Mar 23, 2005 6:28 am ] |
Post subject: | |
Why doesnt Java like the formula: return (X / 100 * 60) + (Y / 100 * 40) / 2; |
Author: | pevil [ Wed Mar 23, 2005 8:30 am ] |
Post subject: | |
coz its an ass. try making a variable that works that out, then just return the variable. |
Author: | derf [ Wed Mar 23, 2005 10:11 am ] |
Post subject: | |
I shouldnt need to because the class specification im working with doesnt include a variable as an attribute. It merely sais that a method will suffice. |
Author: | pevil [ Wed Mar 23, 2005 12:53 pm ] |
Post subject: | |
hmmm well its like 2 years since i did java now... not something daft like the method itself being declared wrong so its unable to return anything? whats the error its giving you? |
Author: | derf [ Thu Mar 24, 2005 6:23 am ] |
Post subject: | |
Its not returning an error, its retirning 0.0 as a value. Ill mess around with data types, see if that gets me anywhere. |
Page 1 of 4 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |