Learn Computer Programming Free from our source codes in my website.
Sponsored Link Please Support
https://www.techseries.dev/a/27966/qWm8FwLb
https://www.techseries.dev/a/19181/qWm8FwLb
My Personal Website is http://www.jakerpomperada.com
Email me at jakerpomperada@gmail.com and jakerpomperada@yahoo.com
Monday, December 9, 2024
Sunday, December 8, 2024
Thursday, December 5, 2024
Monday, November 11, 2024
Friday, November 8, 2024
Wednesday, November 6, 2024
Monday, November 4, 2024
Age Checker in Delphi
Program Listing
unit demo;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ToolWin, Vcl.ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
function AskToQuit: Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
// Programmer : Dr. Jake R. Pomperada
// Date : November 4, 2024
procedure TForm1.Button1Click(Sender: TObject);
var
age: Integer;
begin
try
age := StrToInt(edit1.Text);
if age >= 18 then
label2.Caption := 'You are an adult. At age of ' +IntToStr(age) + ' years old.'
else
label2.Caption := 'You are a minor. At age of ' +IntToStr(age) + ' years old.';
except
on EConvertError do
ShowMessage('Please enter a valid age (a number).');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label2.Caption := '';
edit1.text := '';
edit1.SetFocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if AskToQuit then
Close // Close the form if user confirms
else
edit1.SetFocus;
end;
function TForm1.AskToQuit: Boolean;
begin
Result := MessageDlg('Are you sure you want to quit?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// Optionally adjust the form position here if needed
// For example, move it slightly to the left and up
Left := (Screen.Width - Width) div 2; // Center horizontally
Top := (Screen.Height - Height) div 2; // Center vertically
end;
end.
Sunday, November 3, 2024
Circle Using a Class in Java
Program Listing
import java.text.DecimalFormat;
class Circle {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
public double getRadius() {
return radius;
}
public double calculateArea() {
return Math.PI * Math.pow(radius, 2);
}
public double calculateCircumference() {
return 2 * Math.PI * radius;
}
}
public class Main {
public static void main(String[] args) {
Circle circle = new Circle(8.15);
DecimalFormat df = new DecimalFormat("#.00");
System.out.println("\n\tCircle Using a Class in Java\n");
System.out.println("\tRadius: " + df.format(circle.getRadius()));
System.out.println("\tArea: " + df.format(circle.calculateArea()));
System.out.println("\tCircumference: " + df.format(circle.calculateCircumference()));
System.out.println("\n\tEnd of Program. Thank you for Using This Program\n");
}
}
Wednesday, October 30, 2024
Tuesday, October 29, 2024
Monday, October 28, 2024
Saturday, October 26, 2024
Thursday, October 24, 2024
Wednesday, October 23, 2024
Temperature Converter Using a Class in Python
Program Listing
class TemperatureConverter:
@staticmethod
def celsius_to_fahrenheit(celsius):
return (celsius * 9 / 5) + 32
@staticmethod
def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) * 5 / 9
celsius_temperature = 34.36
fahrenheit_temperature = 134.98
print("\n\tTemperature Converter Using a Class in Python\n")
print("\tCelsius to Fahrenheit: {:.2f}°C = {:.2f}°F".format(celsius_temperature, TemperatureConverter.celsius_to_fahrenheit(celsius_temperature)))
print("\tFahrenheit to Celsius: {:.2f}°F = {:.2f}°C".format(fahrenheit_temperature, TemperatureConverter.fahrenheit_to_celsius(fahrenheit_temperature)))
print("\n\tEnd of Program. Thank you for Using This Program\n")


