Why cannot we use static keyword inside a method in java?

Questions is how can we use if statements in writing our own method in java?

  • like i am doing 3 caculations in my own method with if statements but i am unable to do so. This is my own method that i have written public static double calculateFine (double velocity) { if ((velocity > 20) || (velocity < 31)) { double velocity2 = velocity * 3.00; return velocity2; } else if ((velocity < 30) || (velocity <= 40)) { double velocity2 = velocity * 8.00; return velocity2; } else if (velocity > 40) { double velocity2 = velocity * 12.00; return velocity2; } }

  • Answer:

    There's nothing wrong with your code, but your logic is a bit off. In the first if statement, you probably mean AND (&&) rather than OR (||). In the second you probably want to say "velocity > 30 && velocity <=40."

MM at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.