MySQL Blog
http://mysqlearner.blogspot.com/
MySQL Blog
http://mysqlearner.blogspot.com/
Zeeshan Sheikh wrote:Here is the complete solution.
Hope this helps
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
MySQL Blog
http://mysqlearner.blogspot.com/
MySQL Blog
http://mysqlearner.blogspot.com/
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ryan Sykes wrote:
PS - if you have learnt about ternary operators, then this would be a more succinct way of expressing this part of your code:
Heather Hamrick wrote:ne.showInputDialog("Enter integer, enter -1 to quit");
// >>>how do I call the boolean method so that it runs?
public static boolean isEven(int integer)
{
String message1 = "";
String message2 = "";
while (integer != -1)
} //<<< error says it is "missing a return statement", I'm not sure what to do here.
MySQL Blog
http://mysqlearner.blogspot.com/
Zeeshan Sheikh wrote:As per your method signature it should always return a value, in your case use return true after while block.
MySQL Blog
http://mysqlearner.blogspot.com/
Heather Hamrick wrote:so instead of doing "return true;" what kind of return should I use?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:next...there will probably be some discussion about me using a returnVal variable. There is a lot of debate over whether a method should ever have more than one return statement. Many people feel there should only ever be one, and this is the idiom for doing that. I could have just as easily written the method without it, and done this:
fred rosenberger wrote:
Jeff Verdegan wrote:
I'm gonna have to go ahead and disagree with you there. In this particular case you don't need to set it to something by default, and in general, you should not.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Heather Hamrick wrote:its messed up...help
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
MySQL Blog
http://mysqlearner.blogspot.com/
Heather Hamrick wrote:Alrighttt, I have rewritten my entire program
Heather Hamrick wrote:I have a while loop because thats what my professor has told us to do within our program, so I guess that should be in my main?
Heather Hamrick wrote:the purpose of the loop is to have the program keep running until -1 is entered.
Heather Hamrick wrote:Within the while loop should be an if/else statement that test something like..
..
if(myAnswer ==true)
JOptionPane(print even)
else
JOptionPane(print odd)
...im not sure what should precede the while loop?
...I guess I would say you would have to call the isEven
Heather Hamrick wrote:myAnswer would come from calling the method as "boolean myAnswer;" , and then you would have to call the method in by doing "myAnswer = ???" to determine if true or false is returned
is that how you get into the loop?
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |