Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 09-14-2008
Lucid15
So,
For our first lab in computer science we need to come up with a program that solves ALL values inputted into the quadratic equation. (imaginary, infinite etc). I have been gone for most classes thus far due to sports... and am really behind. Can anyone satisfy this and then explain it? I'mreally lost. this is wht i have so far
include <FPT.h>
int main()
{
double a,b,c,x1,x2;
a=inD() ; b=inD() ; c=inD();
if (a==0 && b==0 && c==0)
{
outS ("There are infinite solutions");
else {
• 09-14-2008
tabstop
Quote:

Originally Posted by Lucid15
Can anyone satisfy this and then explain it?

Assuming inD and outS are defined in your fpt.h thing, then so far so good. No reason to stop now!
• 09-14-2008
Lucid15
I just dont get the concept of what i need to do really. That is all.
• 09-14-2008
tabstop
Well, do the next bit. How do you know if the answers are imaginary/complex?
• 09-14-2008
Lucid15
if the number within the sqrt is , right? we need to solve for real, imiginary/complex, infinite, and none i believe.
• 09-14-2008
tabstop
is ... what? But assuming you've filled in the blank correctly, then yes. So check for that.

Then you can check for none.

And then what's left over must be "normal".
• 09-14-2008
Lucid15
Sorry i meant to put a 0. After i add all of the exceptions then i ask it to solve the equation at the very end right?
• 09-14-2008
tabstop
Not 0, but negative.
• 09-15-2008
Lucid15
lost
I dont know why but im soo lost.... I have no idea where to go next. and how the program shold work.
• 09-15-2008
Salem
> I have been gone for most classes thus far due to sports
Decide which you want to do.

Unless you're naturally gifted in something that you can just do it with minimal instruction, both endeavours pretty much demand full attention. You simply can't coast your way through programming.

Get all the back lectures, and do all the back exercises and you might begin to catch up.
• 09-15-2008
Lucid15
ok
So i talked to the professor briefly today....
I guess what i really do not understand is where i need to add these "exceptions" in which the quadratic equation can not be solved. for example on the board he wrote...
Code:

```double a,b,c,x; a=inD();b=inD();c=inD(); if(a==0) {if (b==0){_______}else{x=-c/b;outD(x);}} else{x=(-b+sqrt(b*b-4*a*c))/(2*a); outD(x); }```
• 09-15-2008
Lucid15
and i just found out that i will not be missing anymore classes... which is definitely a plus.
• 09-15-2008
Thantos
Well work through the equation and find the parts that would require special handling. And use more whitespace, it helps.
• 09-15-2008
Lucid15
yes, and two roots right?
• 09-15-2008
master5001
Example:
Code:

`#include <complex.h>`
I would post more code... but I think that is a start.. Its not how I would do it if it were my homework, but maybe you will find that of some use.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last