Найди ошибку и напиши исправленный код: Unit2.cpp: 

// Unit2.cpp
#include <vcl.h>
#pragma hdrstop

#include <math.h>
#include "Unit2.h"
#include <iostream>
#include <fstream>

#pragma package(smart_init)

Simulation::Simulation(double mt, double ta, double D, double m0, double dq1, double P, double V0, double q1, double qi, double dt)
{
    this->mt = mt;
    this->ta = ta;
    this->D = D;
    this->m0 = m0;
    this->dq1 = dq1;
    this->P = P;
    this->V0 = V0;
    this->q1 = q1;
    this->qi = qi;
    this->dt = dt;

    g = 9.8;
    Cx = 0.3;
    pb = 1.0;
}

void Simulation::Run(TStringGrid *grid, TChart [club148777612|*chart])
{
    double Sm = D * D * 3.14 / 4; // Площадь поперечного сечения
    double mc = mt / ta;
    double P1 = P;

    FILE [id138107760|*fo] = fopen("text.txt", "w");

    // Заголовки для таблицы
    grid->Cells[0][0] = "t";
    grid->Cells[1][0] = "m";
    grid->Cells[2][0] = "mt";
    grid->Cells[3][0] = "P";
    grid->Cells[4][0] = "V";
    grid->Cells[5][0] = "x";
    grid->Cells[6][0] = "y";
    grid->Cells[7][0] = "Vx";
    grid->Cells[8][0] = "Vy";
    grid->Cells[9][0] = "Xa";

    int k = 0;
    for (int i = 0; i <= 5; i++)
    {
        chart->Series[i]->Clear();
    }

    // Основной цикл вычислений
    for (double q = 35; q <= 40; q++)
    {
        double c = cos(q * 3.14 / 180);
        double s = sin(q * 3.14 / 180);
        double Vx = V0 * c;
        double Vy = V0 * s;
        double t = 0, x = 0, y = 0, V = V0;

        while (y >= 0)
        {
            double m, P;
            if (t <= ta) 
            {
                m = m0 - mc * t;
            }
            else 
            {
                m = m0 - mt;
            }

            // Рычаги и движущие силы
            double Xa = Cx * Sm * 0.5 * pb * V * V;

            double u = dt / m;
            double vx = Vx;
            Vx += u * (P1 - Xa) * c;
            double vy = Vy;
            Vy += u * ((P1 - Xa) * s - m * g);

            V = sqrt(Vx * Vx + Vy * Vy);
            double x0 = x;
            x += Vx * dt;
            double y0 = y;
            y += Vy * dt;
            t += dt;

            // Запись в таблицу
            grid->Cells[0][k + 1] = t;
            grid->Cells[1][k + 1] = m;
            grid->Cells[2][k + 1] = mt;
            grid->Cells[3][k + 1] = P1;
            grid->Cells[4][k + 1] = V;
            grid->Cells[5][k + 1] = x;
            grid->Cells[6][k + 1] = y;
            grid->Cells[7][k + 1] = Vx;
            grid->Cells[8][k + 1] = Vy;
            grid->Cells[9][k + 1] = Xa;

            chart->Series[0]->AddXY(x, y);
            fprintf(fo, "\n t=%f x=%f y=%f q=%f v=%f vx=%f vy=%f xa=%f ", t, x, y, q, V, Vx, Vy, Xa);
            k++;
        }
    }
    fclose(fo);
} Unit2.h

// Unit2.h
#ifndef Unit2H
#define Unit2H

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Grids.hpp>
#include <Chart.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include <Series.hpp>

class Simulation
{
private:
    double mt, ta, D, m0, dq1, P, V0, q1, qi, dt, g, Cx, pb;

public:
    Simulation(double mt, double ta, double D, double m0, double dq1, double P, double V0, double q1, double qi, double dt);
    void Run(TStringGrid *grid, TChart [club148777612|*chart]);
};

#endif Unit1.cpp

// Unit1.cpp
#include <vcl.h>
#pragma hdrstop

#include <math.h>
#include <iostream>
#include <fstream>
#include "Unit1.h"
#include "Unit2.h" // Подключаем наш новый класс

#pragma package(smart_init)
#pragma resource "*.dfm"

TForm1 [club12882504|*Form1];

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}

void __fastcall TForm1::Button1Click(TObject [club1797214|*Sender])
{
    RunSimulation();
}

void TForm1::RunSimulation()
{
    // Получение входных данных из полей ввода
    double mt = Edit1->Text.ToDouble();
    double ta = Edit2->Text.ToDouble();
    double D = Edit3->Text.ToDouble();
    double m0 = Edit4->Text.ToDouble();
    double dq1 = Edit5->Text.ToDouble();
    double P = Edit6->Text.ToDouble();
    double V0 = Edit7->Text.ToDouble();
    double q1 = Edit8->Text.ToDouble();
    double qi = Edit9->Text.ToDouble();
    double dt = Edit10->Text.ToDouble();

    // Создаем экземпляр класса для расчетов
    Simulation sim(mt, ta, D, m0, dq1, P, V0, q1, qi, dt);
    sim.Run(StringGrid1, Chart1);
}