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
18 Replies - 5394 Views - Last Post: 12 February 2011 - 02:06 PM
#16
Re: Finding Distinct roots in quadratic equation
Posted 12 February 2011 - 01:30 PM
#17
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
#18
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:
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:
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;
}
#19
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.
Thanks so much!!
Thanks so much!!

New Topic/Question
Reply




MultiQuote

|