This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!

salvin francis

+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Forum Moderator
salvin francis currently moderates these forums:
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

I am surprised to see this level of complex code being taught in schools. What exactly is not working in your code ? and why are you implementing the sort algorithm instead of using Collections.sort() ?
14 hours ago

Irene Song wrote:Hi, I'm a beginner at programming and I don't understand how I can check if the user's answer is correct. Am I doing this right? ...

  • Does the code run fine or do you see any errors on screen ?
  • I see that you have defined a huge number of instance variables which are not needed (e.g. JPanels)
  • I also see a lot of code duplication here

  • 16 hours ago
    I suggest leaving the code aside for now and try this out on a piece of paper.
    Let's say the product price is $200
    and the discount is 10%
    Ignoring the sales tax, what should be the price after discount and how did you calculate that ?

    As campbell pointed out, if we use your formula: 200*(10/100) it equals $20  
    17 hours ago
    Here's my thoughts,

    While I totally agree with Campbell about "If it ain't broke, don't fix it." and this is pretty much my approach too. But off-lately, I have a slightly different mindset.

    Does the application have a very thorough and working functional test plan in place that covers all usecases ?

    If yes, then the whole app codebase is your playground do as much as refactoring as you wish since you are able test your changes.
    If no, then you will have to take that step first and write test cases first for all the code that might be affected by your refactoring so that you know that it works before and after your refactoring.
    5 days ago
    I am a gamer. I have unlimited re-spawns (lives)
    5 days ago

    Junilu Lacar wrote:...

    Agreed !

    Although I suggested it, I dislike "meetsFalseRequirements". I am having a hard time thinking of a method that succeeds and yet returns false
    5 days ago

    Junilu Lacar wrote:...

    Is incorrect, but you have proved my point.. two negatives in sentence confuse us all.

    Problem statement:
    Given an array of ints, print 'false' if the value '3' appears in the array exactly 3 times and no '3's are next to each other. Otherwise print 'true'.

    Maybe if you called your methods : hasAnyConsecutive3s and meetsFalseRequirements I would agree with you

    Also your check would be:
    5 days ago
    I suggest compareToIgnoreCase() method instead of converting the strings to lower case.
    6 days ago

    colten Short wrote:so what would I add to the original code to make it loop?

    You need to understand the do-while loop first. Did you understand how your while loop prints "Hi" 10 times ?
    As per java tutorials:

    java tutorials wrote:The while statement continually executes a block of statements while a particular condition is true

    Similarly the do-while loop has the feature that the block is executed at least once (the first time) and then the condition is checked. Here's a simple code:
    6 days ago
    Just a small nitpick in your for loop code, while it technically works, we usually wrap our loops in brackets "{ ... }" . Also the initialization of "i" can be done within the loop:

    6 days ago
    Perfect, now, can you change your code to use a do-while loop from a for loop ?
    6 days ago

    Barbara Fischer wrote:... print 'false' if the value '3' appears in the array exactly 3 times and no '3's are next to each other. Otherwise print 'true'...

    I hate it when problem statements have two negatives in the same sentence/context. I don't find it intuitive at all.
    Have a look at this :
    "Push this button to send email"
    "Don't push this button if you don't want to send an email"

    I typically re-word such problem statements to suit my intuition:
    If either input contains "33" or input does not contain exactly 3 "3"s, then print "true". Else print "false"

    I hope this helps you
    6 days ago