Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   Pascal doubt (http://www.programmingforums.org/showthread.php?t=4182)

deathseeker25 May 30th, 2005 3:38 PM

Pascal doubt
 
Well i got a problem in this program i created....Some things are written in portuguese (my language) but i think they're not crucial to solve the problem....

:

Program FormulaResolvente;
uses
crt;
var
A : real;
B : real;
C : real;
D : real; {o k ta dentro da raiz kuadrada da formula resolvente}
X : real; {coordenada X do vertice}
raiz1 : real;
raiz2 : real;
Begin
clrscr;
writeln( 'Introduz o valor de A:' );
readln( A );
writeln( 'Introduz o valor de B:' );
readln( B );
writeln( 'Introduz o valor de C:' );
readln( C );
d:= (b*b)-(4*a*c);
if d < 0 then
writeln('Raizes de nºs negativos nao existem Razz')
else
raiz1:= (-b+sqrt(d))/(2*a);
raiz2:= (-b-sqrt(d))/(2*a);
BEGIN
writeln('1ª Raiz = ',raiz1);
writeln('2ª Raiz = ',raiz2);
END;
X:= (raiz1+raiz2)/2;
Begin
writeln('Coordenada X do vertice : ',X);
writeln('Coordenada Y do vertice : ',(A*sqr(x))+(B*X)+C);
while not keypressed do;
end;
end.


Ok, I´ll say what the problem is: the command "while not keypressed do" just function when D<0..well that's a real big problem because D can also be >0 and then the window closes before showing the coordinate of the vertex of the parable....

Please help me, 'cause I'd want to start doing another program in Pascal and i wnat to finish this today...

Thx

deathseeker25 May 30th, 2005 6:37 PM

Come on people help me.....

Ultemecia May 30th, 2005 9:40 PM

Sorry thise post wont help, but i'm just putting this here to tell you that someones reading it :) . Oh yeah it looks like any Pascal users may not even see your post because this site does not have a spot alocated to Pascal...so you might need to fish around some other forums for an answer. :cool:

deathseeker25 May 31st, 2005 5:40 AM

Quote:

Originally Posted by Ultemecia
Sorry thise post wont help, but i'm just putting this here to tell you that someones reading it :) . Oh yeah it looks like any Pascal users may not even see your post because this site does not have a spot alocated to Pascal...so you might need to fish around some other forums for an answer. :cool:

Yes... :( I think I'll have to do it... :( :(

Ooble May 31st, 2005 9:51 AM

Yeah... someone stick a Pascal forum in, please? I need a laugh.

deathseeker25 May 31st, 2005 3:13 PM

Come on people...you're all good programmers..tell me why aren't you helping me...Don't you understand part of the code or don't you know Pascal???

peace_of_mind May 31st, 2005 3:30 PM

Not a lot of members here know pascal, and that's probably why you haven't had much luck with this. No one is ignoring you. But you have to have some patience. I mean, this thread was just created not even 24 hours ago.

deathseeker25 May 31st, 2005 4:27 PM

Quote:

Originally Posted by peace_of_mind
Not a lot of members here know pascal, and that's probably why you haven't had much luck with this. No one is ignoring you. But you have to have some patience. I mean, this thread was just created not even 24 hours ago.


OK...no problem I'll wait... :D :D

Ooble May 31st, 2005 5:11 PM

I think the problem is to do with your begins and ends. If you indent your code, this becomes much more obvious. In my experience, it's a lot easier if you simply put a begin and end wherever you can. And please, space out your code...
:

Program FormulaResolvente;

uses
        crt;

var
        A : real;
        B : real;
        C : real;
        D : real; {o k ta dentro da raiz kuadrada da formula resolvente}
        X : real; {coordenada X do vertice}
        Y : real; {coordenada Y do vertice}
        raiz1 : real;
        raiz2 : real;

begin
        clrscr;
        writeln ('Introduz o valor de A:');
        readln (A);
        writeln ('Introduz o valor de B:');
        readln (B);
        writeln ('Introduz o valor de C:');
        readln (C);
       
        d := (b * b) - (4 * a * c);
        if d < 0 then
        begin
                writeln ('Raizes de nºs negativos nao existem Razz');
        end
        else
        begin
                raiz1 := (-b + sqrt(d)) / (2 * a);
                raiz2 := (-b - sqrt(d)) / (2 * a);
               
                writeln('1ª Raiz = ', raiz1);
                writeln('2ª Raiz = ', raiz2);
               
                X := (raiz1 + raiz2) / 2;
                Y := (A * sqr(X)) + (B * X) + C;
               
                writeln('Coordenada X do vertice : ', X);
                writeln('Coordenada Y do vertice : ', Y);
        end;
       
        readln;
end.

It hasn't been tested, but that should do it.

deathseeker25 Jun 1st, 2005 11:49 AM

Quote:

Originally Posted by Ooble
I think the problem is to do with your begins and ends. If you indent your code, this becomes much more obvious. In my experience, it's a lot easier if you simply put a begin and end wherever you can. And please, space out your code...
:

Program FormulaResolvente;

uses
        crt;

var
        A : real;
        B : real;
        C : real;
        D : real; {o k ta dentro da raiz kuadrada da formula resolvente}
        X : real; {coordenada X do vertice}
        Y : real; {coordenada Y do vertice}
        raiz1 : real;
        raiz2 : real;

begin
        clrscr;
        writeln ('Introduz o valor de A:');
        readln (A);
        writeln ('Introduz o valor de B:');
        readln (B);
        writeln ('Introduz o valor de C:');
        readln (C);
       
        d := (b * b) - (4 * a * c);
        if d < 0 then
        begin
                writeln ('Raizes de nºs negativos nao existem Razz');
        end
        else
        begin
                raiz1 := (-b + sqrt(d)) / (2 * a);
                raiz2 := (-b - sqrt(d)) / (2 * a);
               
                writeln('1ª Raiz = ', raiz1);
                writeln('2ª Raiz = ', raiz2);
               
                X := (raiz1 + raiz2) / 2;
                Y := (A * sqr(X)) + (B * X) + C;
               
                writeln('Coordenada X do vertice : ', X);
                writeln('Coordenada Y do vertice : ', Y);
        end;
       
        readln;
end.

It hasn't been tested, but that should do it.


Oh yes it's working....thanks a lot pal... :) :)


All times are GMT -5. The time now is 12:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC