Finding Distinct roots in quadratic equation

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 5394 Views - Last Post: 12 February 2011 - 02:06 PM Rate Topic: -----

#16 FatalDecepticon   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 07-February 11

Re: Finding Distinct roots in quadratic equation

Posted 12 February 2011 - 01:30 PM

It says that I'm not permitted to UL that kind of file. I can link the page to where you can download it from my professor though. My link
Was This Post Helpful? 0
  • +
  • -

#17 moobler   User is offline

  • D.I.C Head
  • member icon

Reputation: 143
  • View blog
  • Posts: 224
  • Joined: 21-January 11

Re: Finding Distinct roots in quadratic equation

Posted 12 February 2011 - 01:37 PM

Thanks...Ironically I already have that file downloaded. Apparently one of your classmates was having trouble with another assignment ;)
Was This Post Helpful? 1
  • +
  • -

#18 moobler   User is offline

  • D.I.C Head
  • member icon

Reputation: 143
  • View blog
  • Posts: 224
  • Joined: 21-January 11

Re: Finding Distinct roots in quadratic equation

Posted 12 February 2011 - 01:53 PM

Okay, I think there is only one error in your code.

In the getNumSolutions method, you do this:
if (discriminant > 0) {
    numSolutions = 2;
}

if (discriminant == 0) {
    numSolutions = 1;
} else {
    numSolutions = 0;
}



Since you don't return anything until the end of the method, only the latest value of numSolutions is used. The first if statement is basically completely ignored, since numSolutions will be set to 1 or 0 in the next if-else block, no matter what.

You probably just forgot (or accidentally deleted) the 'else' between the two statements. This works as expected:
if (discriminant > 0) {
    numSolutions = 2;
}else if (discriminant == 0) {
    numSolutions = 1;
} else {
    numSolutions = 0;
}


Was This Post Helpful? 3
  • +
  • -

#19 FatalDecepticon   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 07-February 11

Re: Finding Distinct roots in quadratic equation

Posted 12 February 2011 - 02:06 PM

Dude... I don't think you realize how awesome you are right now. :bananaman:

Thanks so much!!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2