Using cycle operators, write a program that builds a graph of the parametric function on delphi.

Function

x = cos (t) sin (at); y = sin (t) cos (bt); Тн =< t= <Tk и изменяет с шагом Th 

I wrote the code:

 procedure TForm1.BitBtn1Click(Sender: TObject); var x, y, xa, xb, t:real; begin xa:= strToFloat(edit1.Text); xb:= strToFloat(edit2.Text); t:= strToFloat(edit3.Text); chart1.Series[0].Clear; x:= xa; repeat y:=sin(x)*cos(xa); chart1.Series[0].AddY(y); x:= x+t; x:=cos(y)*sin(xb); chart1.Series[0].AddY(y); y:=xb; until x>=xb or y>=xb; end; end. 

Questions:

  1. I get the error expected end but received "expected end, but received," it gives exactly in "until x>=xb or y>=xb;" .
  2. Did I write the program correctly (completely)?
  • 1) format the code, you have a special button for this 2)> I get the error expected end end received "expected end, but received
  • @Igor_bogun, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

The brackets must be set until (x>=xb) or (y>=xb); , but it does not save from a negative answer to the second question.

Update

@Igor_bogun , The task is not entirely clear. Do you need to plot two functions x and y, or is this how parametric calculation of x, y coordinates is described? In any case, you should have a cycle for t, which varies from Tn to Tk with step Th, calculating x and y at each step. And to add a point to the chart, you need to use the TLineSeries.addXY method, not addY.

For example, a parabola chart would look like this:

 for i:=(-30) to 30 do Series1.AddXY(i, i*i); 

Try to build a similar graph first (with your own boundary conditions), after debugging it will be easier to solve your original problem.

  • @Yura Ivanov thanks for the hint with brackets. You can hint about the correctness of the program. For example: statement brackets, etc. - Igor_bogun
  • Updated ovtet - Yura Ivanov
  • @Yura Ivanov Thank you, I will definitely try. - Igor_bogun