### Author Topic: Calculating Volume and surface of the ball using Program  (Read 1117 times)

#### godik

• New member
• Posts: 22
##### Calculating Volume and surface of the ball using Program
« on: October 10, 2018, 05:15:51 pm »
Hello Can Someone help me how can I do this? and when i want to make this program i have to use Button,Tedit,Tlabel.Thank you all.

#### Blaazen

• Hero Member
• Posts: 2754
• POKE 54296,15
##### Re: Calculating Volume and surface of the ball using Program
« Reply #1 on: October 10, 2018, 05:34:53 pm »
Code: Pascal  [Select]
1. uses math;
2. ...
3. volume:=4*pi*power(r, 3)/3;
4. surface:=4*pi*r*r;
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

#### godik

• New member
• Posts: 22
##### Re: Calculating Volume and surface of the ball using Program
« Reply #2 on: October 10, 2018, 05:45:30 pm »
But I have to use button,tedit and tlabel

#### Blaazen

• Hero Member
• Posts: 2754
• POKE 54296,15
##### Re: Calculating Volume and surface of the ball using Program
« Reply #3 on: October 10, 2018, 05:51:03 pm »
I guess user will fill the radius of the ball to the edit. You have to convert it from string to integer with r:=strtoint(Edit1.Text);

You can do it in event Button1.OnClick, together with the formulas above. And result write to the label, using Label1.Caption:=inttostr(Volume);

Just try yourself or show us what you already have.
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

#### Handoko

• Hero Member
• Posts: 2852
• My goal: build my own game engine using Lazarus
##### Re: Calculating Volume and surface of the ball using Program
« Reply #4 on: October 10, 2018, 05:51:35 pm »
@godik

It sounds like a homework.

Have you wrote something? Show us your code. If none, you should try to do it your best first then post your code here, so others can guide you.

#### Soner

• Full Member
• Posts: 109
##### Re: Calculating Volume and surface of the ball using Program
« Reply #5 on: October 10, 2018, 09:10:04 pm »

#### Bart

• Hero Member
• Posts: 3312
##### Re: Calculating Volume and surface of the ball using Program
« Reply #6 on: October 12, 2018, 03:02:54 pm »
Use a TFloatSpinEdit, no need to convert to and from string, it has a Value property.

Bart