Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:37:15+00:00 2026-05-19T23:37:15+00:00

this is my program… i need help how i can use function CalkaNadmiar for

  • 0

this is my program… i need help how i can use function CalkaNadmiar for 2: in (case rgMetoda.ItemIndex of) and function CalkaNiedomiar for 3:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  fx= function(x:extended):extended;
  TForm1 = class(TForm)
    Naglowek: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    edPrzedzialy: TEdit;
    edOd: TEdit;
    edDo: TEdit;
    pnWynik: TPanel;
    Oblicz: TButton;
    rgMetoda: TRadioGroup;
    rb1: TRadioButton;
    rb2: TRadioButton;
    rb3: TRadioButton;

    function f1(X: Extended): Extended;
    function f2(X: Extended): Extended;
    function f3(X: Extended): Extended;
    procedure ObliczClick(Sender: TObject);
    procedure edPrzedzialyExit(Sender: TObject);
    procedure edOdExit(Sender: TObject);
    procedure edDoExit(Sender: TObject);




  private
         function CalkaNadmiar (odx,dox:extended; n:integer; f:fx):extended;
     function CalkaNiedomiar (odx,dox:extended; n:integer; f:fx):extended;
     function Calka (odx,dox:extended; n:integer; f:fx):extended;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.f1(x: Extended): Extended;
begin
 Result:=sqr(x)+ 2;
end;

function TForm1.f2(X: Extended): Extended;
begin
 Result:=3*x - 8;
end;

function TForm1.f3(X: Extended): Extended;
begin
 Result:=sin(x) + Pi;
end;


 procedure TForm1.ObliczClick(Sender: TObject);
var Wynik, h, xi: real;
    i,n: word;
//h - krok całkowania
// Wynik - chwilowy lub końcowy wynik danej funkcji
//xi - x dla kolejnego kroku całkowania
//n - liczba przedziałów
//i - obsluga pętli
begin
 n:=StrToInt(edPrzedzialy.Text);
 h:=(StrToFloat(edDo.Text)-StrToFloat(edOd.Text))/n;
 Wynik:=0;
 case rgMetoda.ItemIndex of
  0: begin //obsługa metody prostok±tów z nadmiarem
   if rb1.Checked then
    begin
     for i:=0 to n-1 do
      begin
       xi:=StrToFloat(edOd.Text)+i*h;
       Wynik:= Wynik + f1(xi)*h;
      end;
     pnWynik.Caption:= FloatToStr(Wynik);
    end;
   if rb2.Checked then
    begin
     for i:=0 to n-1 do
      begin
       xi:=StrToFloat(edOd.Text)+i*h;
       Wynik:= Wynik + f2(xi)*h;
       end;
        pnWynik.Caption:= FloatToStr(Wynik);
      end;
    if rb3.Checked then
      begin
       for i:=0 to n-1 do
        begin
         xi:=StrToFloat(edOd.Text)+i*h;
         Wynik:= Wynik + f3(xi)*h;
      end;
     pnWynik.Caption:=FloatToStr(Wynik);
   end;
   end;


  1: begin //obsługa metody prostok±tów z niedomiarem
   if rb1.Checked then
    begin
     for i:=1 to n do
      begin
       xi:= StrToFloat(edOd.Text) + i*h;
       Wynik:= Wynik + f1(xi)*h;
      end;
     pnWynik.Caption := FloatToStr(Wynik);
    end;
   if rb2.Checked then
    begin
     for i:=1 to n do
      begin
       xi:=StrToFloat(edOd.Text) + i*h;
       Wynik:= Wynik + f2(xi)*h;
      end;
     pnWynik.Caption:=FloatToStr(Wynik);
    end;
         if rb3.Checked then
      begin
       for i:=0 to n-1 do
        begin
         xi:=StrToFloat(edOd.Text)+i*h;
         Wynik:= Wynik + f3(xi)*h;
      end;
     pnWynik.Caption:=FloatToStr(Wynik);
  end;
end;
end;
end;


procedure TForm1.edPrzedzialyExit(Sender: TObject);
begin
 if (StrToFloat(edPrzedzialy.Text)<10000) or
    (StrToFloat(edPrzedzialy.Text)>100000000)
 then
  begin
   showmessage('Podaj liczbę z przedziału [10000 - 100000000].');
   edPrzedzialy.SetFocus;
  end;
 if Frac(StrToFloat(edPrzedzialy.Text))<>0 then
{sprawdzamy czy została wprowadzona liczba całkowita}
  begin
   showmessage('Podaj liczbę całkowitą.');
   edPrzedzialy.SetFocus;
  end;
end;

procedure TForm1.edOdExit(Sender: TObject);
begin
 if StrToFloat(edOd.Text)>=StrToFloat(edDo.Text) then
  begin
   showmessage('Podaj liczbę mniejsz± niż górna granica całkowania.');
   edOd.SetFocus;
  end;
end;

procedure TForm1.edDoExit(Sender: TObject);
begin
if StrToFloat(edDo.Text)<=StrToFloat(edOd.Text) then
  begin
   showmessage('Podaj liczbę większą niż dolna granica całkowania.');
   edDo.SetFocus;
  end;
  end;

  function TForm1.CalkaNadmiar (odx,dox:extended; n:integer; f:fx):extended; //trapez z nadmiarem
var i:integer;  xi,h,Wynik:extended;
begin
    Wynik:=0;
    h:=(Dox-Odx)/n;
for i:= 0 to n-1 do
    begin
        Wynik:=f(xi)*h+Wynik;
        xi:=xi+h;
    end;
    Result:=Wynik;
 end;

    function TForm1.CalkaNiedomiar (odx,dox:extended; n:integer; f:fx):extended; //trapez z niedomiarem
var i:integer;  xi,h,Wynik:extended;
begin
    Wynik:=0;
    h:=(Dox-Odx)/n;
for i:= 1 to n do
    begin
        Wynik:=f(xi)*h+Wynik;
        xi:=xi+h;
    end;
    Result:=Wynik;
end;

 function TForm1.Calka (odx,dox:extended; n:integer; f:fx):extended;  //trapez
 var i:integer;  xi,h,Wynik:extended;
begin
    Wynik:=0;
    h:=(Dox-Odx)/n;
for i:= 1 to n-1 do
    begin
        Wynik:=f(xi)+Wynik;
        xi:=xi+h;
    end;
    Wynik:=(f(odx) + f(dox) + Wynik)*h/2;
    Result:=Wynik;
end;


end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:37:15+00:00Added an answer on May 19, 2026 at 11:37 pm

    I think this will be helpful to you

    case ( rgMetoda.ItemIndex ) of
      2 : begin CalkaNadmiar;    end;
    
      3 : begin CalkaNiedomiar; end;   
    
      else begin               
        //Call other function
      end;
    end; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This program is written in C++. I am trying to use a void function
This program I use has it's own variables to set when you run it,
This program adds two matrices but it's giving too many errors and I can't
In this program I'm parsing input into integers and I can't seem to be
Okay so I made this program to help me out with my homework and
In this program, how can break execution with the debugger and print the value
In this program I am trying to create a simple calculator. However, I can't
This program is to use the keyboard keys to play notes. I get a
This program creates five threads, each executing the function TaskCode that prints the unique
This program is supposed to create a button that the user can press to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.