Thursday, July 9, 2009

Can't seem to get this to work, please help!?

I am using Gnu 2.1.73 and SciTE





fprintf('\nThis program solves the equation ax^2+bx+c=0 for x.\n\n');


a = input('Enter the coefficient a: ');


b = input('Enter the coefficient b: ');


c = input('Enter the coefficient c: ');


(d = b^2+4*a*c);


if (a==b==c==0)


fprintf('all possible solutions\n');


elseif (a==b==0)


fprintf('no possible solutions\n');


elseif (d %26lt; 0)


fprintf('no real solutions\n');


elseif (d==0)


x = -b/(2*a)


fprintf('%3.2f.\n', x);


else (d %26gt; 0)


(x1 = ((-b+d^1/2)/(2*a)));


(x2 = ((-b-d^1/2)/(2*a)));


fprintf('The quadratic equation has two solutions:');


disp([x1 x2]);


end

Can't seem to get this to work, please help!?
Possibly because you forgot a semicolon here? I don't know this syntax, but if it requires a semicolon after certain lines then...





fprintf('no real solutions\n');


elseif (d==0)


x = -b/(2*a)


fprintf('%3.2f.\n', x);


else (d %26gt; 0)





x = -b/(2*a) does not have a semicolon after it.
Reply:DUHHHH!!!!!!!!!!





If I could answer that, I wouldn't need my TI-84 Plus!!!!





Hell, I barely passed general math!
Reply:the math is good.





i don't know the syntax for what you're using, but the ecuation solving is correct.


No comments:

Post a Comment